private static string GetMimeTypePartialClassSouceCode(MimeTypeGroup group) { var subtypeSourceCode = new StringBuilder(); foreach (var subType in group.All()) { subtypeSourceCode.AppendLine( $" public static MimeType {subType.LegalSubTypeName} {{ get; }} = new MimeType(\"{subType.TypeName}\", \"{subType.SubTypeName}\");"); } return ($@" public static class {group.LegalTypeName} {{ public const string Type = ""{group.TypeName}""; {subtypeSourceCode} public static IEnumerable<MimeType> All() {{ return GetMimeTypeProperties(typeof(Application)); }} }} "); }
public void Add(string type, string subtype, string extension) { if (!_mimeTypeDictionary.TryGetValue(type, out var mimeGroup)) { mimeGroup = new MimeTypeGroup(type); _mimeTypeDictionary.Add(type, mimeGroup); } mimeGroup.Add(subtype, extension); }