Beispiel #1
0
 // PROTECTED CONSTRUCTORS ///////////////////////////////////////////
 #region Constructors
 protected ExtensibleObject()
 {
     this.ExtensionDictionary = new Lazy <ExtensionDictionary <T> >(() =>
     {
         var extensionOwner      = this.ExtensionOwner;
         var extensionDictionary = new ExtensionDictionary <T>(extensionOwner);
         return(extensionDictionary);
     }, LazyThreadSafetyMode.PublicationOnly);
 }
        public static void Add(MimeType mimeType, params string[] extensions)
        {
            if (!ExtensionDictionary.TryGetValue(mimeType, out var extensionSet))
            {
                extensionSet = new HashSet <string>();
                ExtensionDictionary.Add(mimeType, extensionSet);
            }

            foreach (var extension in extensions)
            {
                extensionSet.Add(extension);
            }
        }
 public static IEnumerable <string> All(MimeType mimeType)
 {
     return(ExtensionDictionary.TryGetValue(mimeType, out var extensionSet)
         ? extensionSet.ToList()
         : new List <string>());
 }
 public static IEnumerable <MimeType> Get(string extension)
 {
     return(ExtensionDictionary.Where(pair => pair.Value.Contains(extension)).Select(pair => pair.Key));
 }