static BasicMimeTypesX()
        {
            MTIDict_ByEnums      = AllTypes.ToDictionary(v => v.MimeType, v => v);
            MTIDict_ByMimeNames  = AllTypes.ToDictionary(v => v.MimeTypeString, v => v);
            MTIDict_ByExtensions = AllTypes.Where(v => v.Extension.NotNulle()).ToDictionary(v => v.Extension, v => v);

            for (int i = 0; i < AllTypes.Length; i++)
            {
                MTI mti = AllTypes[i];

                if (mti.ExtraMimeStrings.NotNulle())
                {
                    foreach (string extMimeStr in mti.ExtraMimeStrings)
                    {
                        if (!MTIDict_ByMimeNames.ContainsKey(extMimeStr))
                        {
                            MTIDict_ByMimeNames.Add(extMimeStr, mti);
                        }
                    }
                }

                if (mti.ExtraExtensions.NotNulle())
                {
                    foreach (string ext in mti.ExtraExtensions)
                    {
                        if (!MTIDict_ByExtensions.ContainsKey(ext))
                        {
                            MTIDict_ByExtensions.Add(ext, mti);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static MTI AddExtraExtensions(this MTI m, params string[] exts)
        {
            if (m.ExtraExtensions == null)
            {
                m.ExtraExtensions = new List <string>();
            }

            foreach (string ext in exts)
            {
                string x = ext.NullIfEmptyTrimmed();
                if (x != null)
                {
                    m.ExtraExtensions.Add(x);
                }
            }
            return(m);
        }
Ejemplo n.º 3
0
        public static MTI ExtraMimeStrings(this MTI m, params string[] mimeStrs)
        {
            if (m.ExtraMimeStrings == null)
            {
                m.ExtraMimeStrings = new List <string>();
            }

            foreach (string mim in mimeStrs)
            {
                string _mim = mim.NullIfEmptyTrimmed();
                if (_mim != null)
                {
                    m.ExtraMimeStrings.Add(_mim);
                }
            }
            return(m);
        }
Ejemplo n.º 4
0
        // --- +++ ---

        public static MTI AddExtraExtension(this MTI m, string ext)
        {
            string x = ext.NullIfEmptyTrimmed();

            if (x == null)
            {
                throw new ArgumentNullException();
            }

            if (m.ExtraExtensions == null)
            {
                m.ExtraExtensions = new List <string>();
            }

            m.ExtraExtensions.Add(x);
            return(m);
        }