Added audio recording (#615)
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

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-01-07 12:56:11 +01:00
1 parent 724cf55293
commit 324ea9eb73
34 files changed
+868 -31

No files matched your search

@@ -0,0 +1,67 @@
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
}
@@ -0,0 +1,21 @@
namespace AIStudio.Tools.MIME;
public enum ApplicationSubtype
{
OCTET_STREAM,
JSON,
XML,
PDF,
ZIP,
X_WWW_FORM_URLENCODED,
WORD_OLD,
WORD,
EXCEL_OLD,
EXCEL,
POWERPOINT_OLD,
POWERPOINT,
}
@@ -0,0 +1,51 @@
namespace AIStudio.Tools.MIME;
public class AudioBuilder : ISubtype
{
private const BaseType BASE_TYPE = BaseType.AUDIO;
private AudioBuilder()
{
}
public static AudioBuilder Create() => new();
private AudioSubtype subtype;
public AudioBuilder UseSubtype(string subType)
{
this.subtype = subType.ToLowerInvariant() switch
{
"mpeg" => AudioSubtype.MPEG,
"wav" => AudioSubtype.WAV,
"ogg" => AudioSubtype.OGG,
"aac" => AudioSubtype.AAC,
"flac" => AudioSubtype.FLAC,
"webm" => AudioSubtype.WEBM,
"mp4" => AudioSubtype.MP4,
"mp3" => AudioSubtype.MP3,
"m4a" => AudioSubtype.M4A,
"aiff" => AudioSubtype.AIFF,
_ => throw new ArgumentException("Unsupported MIME audio subtype.", nameof(subType))
};
return this;
}
public AudioBuilder UseSubtype(AudioSubtype subType)
{
this.subtype = subType;
return this;
}
#region Implementation of IMIMESubtype
public MIMEType Build() => new()
{
Type = this,
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
};
#endregion
}
@@ -0,0 +1,16 @@
namespace AIStudio.Tools.MIME;
public enum AudioSubtype
{
WAV,
MP3,
OGG,
AAC,
FLAC,
// ReSharper disable once InconsistentNaming
M4A,
MPEG,
MP4,
WEBM,
AIFF
}
@@ -0,0 +1,10 @@
namespace AIStudio.Tools.MIME;
public enum BaseType
{
APPLICATION,
AUDIO,
IMAGE,
VIDEO,
TEXT,
}
@@ -0,0 +1,58 @@
namespace AIStudio.Tools.MIME;
public class Builder
{
private Builder()
{
}
public static Builder Create() => new();
public static MIMEType FromTextRepresentation(string textRepresentation)
{
var parts = textRepresentation.Split('/');
if (parts.Length != 2)
throw new ArgumentException("Invalid MIME type format.", nameof(textRepresentation));
var baseType = parts[0].ToLowerInvariant();
var subType = parts[1].ToLowerInvariant();
var builder = Create();
switch (baseType)
{
case "application":
var appBuilder = builder.UseApplication();
return appBuilder.UseSubtype(subType).Build();
case "text":
var textBuilder = builder.UseText();
return textBuilder.UseSubtype(subType).Build();
case "audio":
var audioBuilder = builder.UseAudio();
return audioBuilder.UseSubtype(subType).Build();
case "image":
var imageBuilder = builder.UseImage();
return imageBuilder.UseSubtype(subType).Build();
case "video":
var videoBuilder = builder.UseVideo();
return videoBuilder.UseSubtype(subType).Build();
default:
throw new ArgumentException("Unsupported base type.", nameof(textRepresentation));
}
}
public ApplicationBuilder UseApplication() => ApplicationBuilder.Create();
public TextBuilder UseText() => TextBuilder.Create();
public AudioBuilder UseAudio() => AudioBuilder.Create();
public ImageBuilder UseImage() => ImageBuilder.Create();
public VideoBuilder UseVideo() => VideoBuilder.Create();
}
@@ -0,0 +1,6 @@
namespace AIStudio.Tools.MIME;
public interface ISubtype
{
public MIMEType Build();
}
@@ -0,0 +1,48 @@
namespace AIStudio.Tools.MIME;
public class ImageBuilder : ISubtype
{
private const BaseType BASE_TYPE = BaseType.IMAGE;
private ImageBuilder()
{
}
public static ImageBuilder Create() => new();
private ImageSubtype subtype;
public ImageBuilder UseSubtype(string subType)
{
this.subtype = subType.ToLowerInvariant() switch
{
"jpeg" or "jpg" => ImageSubtype.JPEG,
"png" => ImageSubtype.PNG,
"gif" => ImageSubtype.GIF,
"webp" => ImageSubtype.WEBP,
"tiff" or "tif" => ImageSubtype.TIFF,
"svg+xml" or "svg" => ImageSubtype.SVG,
"heic" => ImageSubtype.HEIC,
_ => throw new ArgumentException("Unsupported MIME image subtype.", nameof(subType))
};
return this;
}
public ImageBuilder UseSubtype(ImageSubtype subType)
{
this.subtype = subType;
return this;
}
#region Implementation of IMIMESubtype
public MIMEType Build() => new()
{
Type = this,
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
};
#endregion
}
@@ -0,0 +1,12 @@
namespace AIStudio.Tools.MIME;
public enum ImageSubtype
{
JPEG,
PNG,
GIF,
TIFF,
WEBP,
SVG,
HEIC,
}
@@ -0,0 +1,16 @@
namespace AIStudio.Tools.MIME;
public record MIMEType
{
public required ISubtype Type { get; init; }
public required string TextRepresentation { get; init; }
#region Overrides of Object
public override string ToString() => this.TextRepresentation;
#endregion
public static implicit operator string(MIMEType mimeType) => mimeType.TextRepresentation;
}
@@ -0,0 +1,15 @@
namespace AIStudio.Tools.MIME;
public static class MIMETypeExtensions
{
public static string[] ToStringArray(this MIMEType[] mimeTypes)
{
var result = new string[mimeTypes.Length];
for (var i = 0; i < mimeTypes.Length; i++)
{
result[i] = mimeTypes[i];
}
return result;
}
}
@@ -0,0 +1,49 @@
namespace AIStudio.Tools.MIME;
public class TextBuilder : ISubtype
{
private const BaseType BASE_TYPE = BaseType.TEXT;
private TextBuilder()
{
}
public static TextBuilder Create() => new();
private TextSubtype subtype;
public TextBuilder UseSubtype(string subType)
{
this.subtype = subType.ToLowerInvariant() switch
{
"plain" => TextSubtype.PLAIN,
"html" => TextSubtype.HTML,
"css" => TextSubtype.CSS,
"csv" => TextSubtype.CSV,
"javascript" => TextSubtype.JAVASCRIPT,
"xml" => TextSubtype.XML,
"markdown" => TextSubtype.MARKDOWN,
"json" => TextSubtype.JSON,
_ => throw new ArgumentException("Unsupported MIME text subtype.", nameof(subType))
};
return this;
}
public TextBuilder UseSubtype(TextSubtype subType)
{
this.subtype = subType;
return this;
}
#region Implementation of IMIMESubtype
public MIMEType Build() => new()
{
Type = this,
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
};
#endregion
}
@@ -0,0 +1,13 @@
namespace AIStudio.Tools.MIME;
public enum TextSubtype
{
PLAIN,
HTML,
CSS,
CSV,
JAVASCRIPT,
XML,
JSON,
MARKDOWN,
}
@@ -0,0 +1,46 @@
namespace AIStudio.Tools.MIME;
public class VideoBuilder : ISubtype
{
private const BaseType BASE_TYPE = BaseType.VIDEO;
private VideoBuilder()
{
}
public static VideoBuilder Create() => new();
private VideoSubtype subtype;
public VideoBuilder UseSubtype(string subType)
{
this.subtype = subType.ToLowerInvariant() switch
{
"mp4" => VideoSubtype.MP4,
"webm" => VideoSubtype.WEBM,
"avi" => VideoSubtype.AVI,
"mov" => VideoSubtype.MOV,
"mkv" => VideoSubtype.MKV,
_ => throw new ArgumentException("Unsupported MIME video subtype.", nameof(subType))
};
return this;
}
public VideoBuilder UseSubtype(VideoSubtype subType)
{
this.subtype = subType;
return this;
}
#region Implementation of IMIMESubtype
public MIMEType Build() => new()
{
Type = this,
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
};
#endregion
}
@@ -0,0 +1,11 @@
namespace AIStudio.Tools.MIME;
public enum VideoSubtype
{
MP4,
AVI,
MOV,
MKV,
WEBM,
MPEG,
}