mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 03:41:37 +00:00
Refactor to use constants for BaseType in MIME builders
This commit is contained in:
parent
6bb6baced9
commit
31147025ff
@ -2,14 +2,13 @@ namespace AIStudio.Tools.MIME;
|
||||
|
||||
public class ApplicationBuilder : ISubtype
|
||||
{
|
||||
private readonly BaseType baseType;
|
||||
|
||||
private ApplicationBuilder(BaseType baseType)
|
||||
private const BaseType BASE_TYPE = BaseType.APPLICATION;
|
||||
|
||||
private ApplicationBuilder()
|
||||
{
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public static ApplicationBuilder Create() => new(BaseType.APPLICATION);
|
||||
public static ApplicationBuilder Create() => new();
|
||||
|
||||
private ApplicationSubtype subtype;
|
||||
|
||||
@ -52,15 +51,15 @@ public class ApplicationBuilder : ISubtype
|
||||
Type = this,
|
||||
TextRepresentation = this.subtype switch
|
||||
{
|
||||
ApplicationSubtype.EXCEL_OLD => $"{this.baseType}/vnd.ms-excel".ToLowerInvariant(),
|
||||
ApplicationSubtype.WORD_OLD => $"{this.baseType}/vnd.ms-word".ToLowerInvariant(),
|
||||
ApplicationSubtype.POWERPOINT_OLD => $"{this.baseType}/vnd.ms-powerpoint".ToLowerInvariant(),
|
||||
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 => $"{this.baseType}/vnd.openxmlformats-officedocument.spreadsheetml.sheet".ToLowerInvariant(),
|
||||
ApplicationSubtype.WORD => $"{this.baseType}/vnd.openxmlformats-officedocument.wordprocessingml.document".ToLowerInvariant(),
|
||||
ApplicationSubtype.POWERPOINT => $"{this.baseType}/vnd.openxmlformats-officedocument.presentationml.presentation".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(),
|
||||
|
||||
_ => $"{this.baseType}/{this.subtype}".ToLowerInvariant()
|
||||
_ => $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,14 +2,13 @@ namespace AIStudio.Tools.MIME;
|
||||
|
||||
public class AudioBuilder : ISubtype
|
||||
{
|
||||
private readonly BaseType baseType;
|
||||
|
||||
private AudioBuilder(BaseType baseType)
|
||||
private const BaseType BASE_TYPE = BaseType.AUDIO;
|
||||
|
||||
private AudioBuilder()
|
||||
{
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public static AudioBuilder Create() => new(BaseType.AUDIO);
|
||||
public static AudioBuilder Create() => new();
|
||||
|
||||
private AudioSubtype subtype;
|
||||
|
||||
@ -45,7 +44,7 @@ public class AudioBuilder : ISubtype
|
||||
public MIMEType Build() => new()
|
||||
{
|
||||
Type = this,
|
||||
TextRepresentation = $"{this.baseType}/{this.subtype}".ToLowerInvariant()
|
||||
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,14 +2,13 @@ namespace AIStudio.Tools.MIME;
|
||||
|
||||
public class ImageBuilder : ISubtype
|
||||
{
|
||||
private readonly BaseType baseType;
|
||||
|
||||
private ImageBuilder(BaseType baseType)
|
||||
private const BaseType BASE_TYPE = BaseType.IMAGE;
|
||||
|
||||
private ImageBuilder()
|
||||
{
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public static ImageBuilder Create() => new(BaseType.IMAGE);
|
||||
public static ImageBuilder Create() => new();
|
||||
|
||||
private ImageSubtype subtype;
|
||||
|
||||
@ -42,7 +41,7 @@ public class ImageBuilder : ISubtype
|
||||
public MIMEType Build() => new()
|
||||
{
|
||||
Type = this,
|
||||
TextRepresentation = $"{this.baseType}/{this.subtype}".ToLowerInvariant()
|
||||
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,14 +2,13 @@ namespace AIStudio.Tools.MIME;
|
||||
|
||||
public class TextBuilder : ISubtype
|
||||
{
|
||||
private readonly BaseType baseType;
|
||||
|
||||
private TextBuilder(BaseType baseType)
|
||||
private const BaseType BASE_TYPE = BaseType.TEXT;
|
||||
|
||||
private TextBuilder()
|
||||
{
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public static TextBuilder Create() => new(BaseType.TEXT);
|
||||
public static TextBuilder Create() => new();
|
||||
|
||||
private TextSubtype subtype;
|
||||
|
||||
@ -43,7 +42,7 @@ public class TextBuilder : ISubtype
|
||||
public MIMEType Build() => new()
|
||||
{
|
||||
Type = this,
|
||||
TextRepresentation = $"{this.baseType}/{this.subtype}".ToLowerInvariant()
|
||||
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
@ -2,14 +2,13 @@ namespace AIStudio.Tools.MIME;
|
||||
|
||||
public class VideoBuilder : ISubtype
|
||||
{
|
||||
private readonly BaseType baseType;
|
||||
|
||||
private VideoBuilder(BaseType baseType)
|
||||
private const BaseType BASE_TYPE = BaseType.VIDEO;
|
||||
|
||||
private VideoBuilder()
|
||||
{
|
||||
this.baseType = baseType;
|
||||
}
|
||||
|
||||
public static VideoBuilder Create() => new(BaseType.VIDEO);
|
||||
public static VideoBuilder Create() => new();
|
||||
|
||||
private VideoSubtype subtype;
|
||||
|
||||
@ -40,7 +39,7 @@ public class VideoBuilder : ISubtype
|
||||
public MIMEType Build() => new()
|
||||
{
|
||||
Type = this,
|
||||
TextRepresentation = $"{this.baseType}/{this.subtype}".ToLowerInvariant()
|
||||
TextRepresentation = $"{BASE_TYPE}/{this.subtype}".ToLowerInvariant()
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user