Exemplo n.º 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);
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public static IEnumerable <string> All(MimeType mimeType)
 {
     return(ExtensionDictionary.TryGetValue(mimeType, out var extensionSet)
         ? extensionSet.ToList()
         : new List <string>());
 }
Exemplo n.º 4
0
 public static IEnumerable <MimeType> Get(string extension)
 {
     return(ExtensionDictionary.Where(pair => pair.Value.Contains(extension)).Select(pair => pair.Key));
 }