Skip to content

Commit 44ecc97

Browse files
committed
define constants for top-level types
1 parent 5d62185 commit 44ecc97

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/Smdn.Fundamental.MimeType/Smdn/MimeType.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ namespace Smdn;
99
*/
1010
[System.Runtime.CompilerServices.TypeForwardedFrom("Smdn, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null")]
1111
public partial class MimeType {
12+
private const string TopLevelTypeApplication = "application";
13+
private const string TopLevelTypeAudio = "audio";
14+
private const string TopLevelTypeImage = "image";
15+
private const string TopLevelTypeMessage = "message";
16+
private const string TopLevelTypeMultipart = "multipart";
17+
private const string TopLevelTypeText = "text";
18+
private const string TopLevelTypeVideo = "video";
19+
private const string TopLevelTypeModel = "model"; // [RFC2077] The Model Primary Content Type for Multipurpose Internet Mail Extensions
20+
private const string TopLevelTypeFont = "font"; // [RFC8081] The "font" Top-Level Media Type
21+
1222
/*
1323
* class members
1424
*/
@@ -22,21 +32,21 @@ public partial class MimeType {
2232
public static readonly MimeType MultipartFormData = CreateMultipartType("form-data"); // [RFC7578]
2333
public static readonly MimeType ApplicationOctetStream = CreateApplicationType("octet-stream"); // [RFC2046]
2434
public static readonly MimeType ApplicationXWwwFormUrlEncoded = CreateApplicationType("x-www-form-urlencoded"); // WHATWG
25-
public static readonly MimeType MessagePartial = new("message", "partial"); // [RFC2046]
26-
public static readonly MimeType MessageExternalBody = new("message", "external-body"); // [RFC2046]
27-
public static readonly MimeType MessageRfc822 = new("message", "rfc822"); // [RFC2046]
35+
public static readonly MimeType MessagePartial = new(TopLevelTypeMessage, "partial"); // [RFC2046]
36+
public static readonly MimeType MessageExternalBody = new(TopLevelTypeMessage, "external-body"); // [RFC2046]
37+
public static readonly MimeType MessageRfc822 = new(TopLevelTypeMessage, "rfc822"); // [RFC2046]
2838

2939
// TODO: rename param `subtype` to `subType`
30-
public static MimeType CreateTextType(string subtype) => new("text", subtype);
31-
public static MimeType CreateImageType(string subtype) => new("image", subtype);
32-
public static MimeType CreateAudioType(string subtype) => new("audio", subtype);
33-
public static MimeType CreateVideoType(string subtype) => new("video", subtype);
34-
public static MimeType CreateApplicationType(string subtype) => new("application", subtype);
35-
public static MimeType CreateMultipartType(string subtype) => new("multipart", subtype);
40+
public static MimeType CreateTextType(string subtype) => new(TopLevelTypeText, subtype);
41+
public static MimeType CreateImageType(string subtype) => new(TopLevelTypeImage, subtype);
42+
public static MimeType CreateAudioType(string subtype) => new(TopLevelTypeAudio, subtype);
43+
public static MimeType CreateVideoType(string subtype) => new(TopLevelTypeVideo, subtype);
44+
public static MimeType CreateApplicationType(string subtype) => new(TopLevelTypeApplication, subtype);
45+
public static MimeType CreateMultipartType(string subtype) => new(TopLevelTypeMultipart, subtype);
3646
// [RFC2077] The Model Primary Content Type for Multipurpose Internet Mail Extensions
37-
public static MimeType CreateModelType(string subtype) => new("model", subtype);
47+
public static MimeType CreateModelType(string subtype) => new(TopLevelTypeModel, subtype);
3848
// [RFC8081] The "font" Top-Level Media Type
39-
public static MimeType CreateFontType(string subtype) => new("font", subtype);
49+
public static MimeType CreateFontType(string subtype) => new(TopLevelTypeFont, subtype);
4050

4151
/*
4252
* instance members

0 commit comments

Comments
 (0)