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