mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 03:41:38 +00:00
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
namespace AIStudio.Tools.MIME;
|
|
|
|
public class ApplicationBuilder : ISubtype
|
|
{
|
|
private const BaseType BASE_TYPE = BaseType.APPLICATION;
|
|
|
|
private ApplicationBuilder()
|
|
{
|
|
}
|
|
|
|
public static ApplicationBuilder Create() => new();
|
|
|
|
private ApplicationSubtype subtype;
|
|
|
|
public ApplicationBuilder UseSubtype(string subType)
|
|
{
|
|
this.subtype = subType.ToLowerInvariant() switch
|
|
{
|
|
"vnd.ms-excel" => ApplicationSubtype.EXCEL_OLD,
|
|
"vnd.ms-word" => ApplicationSubtype.WORD_OLD,
|
|
"vnd.ms-powerpoint" => ApplicationSubtype.POWERPOINT_OLD,
|
|
|
|
"vnd.openxmlformats-officedocument.spreadsheetml.sheet" => ApplicationSubtype.EXCEL,
|
|
"vnd.openxmlformats-officedocument.wordprocessingml.document" => ApplicationSubtype.WORD,
|
|
"vnd.openxmlformats-officedocument.presentationml.presentation" => ApplicationSubtype.POWERPOINT,
|
|
|
|
"octet-stream" => ApplicationSubtype.OCTET_STREAM,
|
|
|
|
"json" => ApplicationSubtype.JSON,
|
|
"xml" => ApplicationSubtype.XML,
|
|
"pdf" => ApplicationSubtype.PDF,
|
|
"zip" => ApplicationSubtype.ZIP,
|
|
|
|
"x-www-form-urlencoded" => ApplicationSubtype.X_WWW_FORM_URLENCODED,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(subType), "Unsupported MIME application subtype.")
|
|
};
|
|
|
|
return this;
|
|
}
|
|
|
|
public ApplicationBuilder UseSubtype(ApplicationSubtype subType)
|
|
{
|
|
this.subtype = subType;
|
|
return this;
|
|
}
|
|
|
|
#region Implementation of IMIMESubtype
|
|
|
|
public MIMEType Build() => new()
|
|
{
|
|
Type = this,
|
|
TextRepresentation = this.subtype switch
|
|
{
|
|
ApplicationSubtype.EXCEL_OLD => $"{BASE_TYPE}/vnd.ms-excel".ToLowerInvariant(),
|
|
ApplicationSubtype.WORD_OLD => $"{BASE_TYPE}/vnd.ms-word".ToLowerInvariant(),
|
|
ApplicationSubtype.POWERPOINT_OLD => $"{BASE_TYPE}/vnd.ms-powerpoint".ToLowerInvariant(),
|
|
|
|
ApplicationSubtype.EXCEL => $"{BASE_TYPE}/vnd.openxmlformats-officedocument.spreadsheetml.sheet".ToLowerInvariant(),
|
|
ApplicationSubtype.WORD => $"{BASE_TYPE}/vnd.openxmlformats-officedocument.wordprocessingml.document".ToLowerInvariant(),
|
|
ApplicationSubtype.POWERPOINT => $"{BASE_TYPE}/vnd.openxmlformats-officedocument.presentationml.presentation".ToLowerInvariant(),
|
|
|
|
_ => $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
|
}
|
|
};
|
|
|
|
#endregion
|
|
} |