private static Dictionary<string, FileEntitySetting> GetFileExtensionsForMatches()
        {
            var fileExtensionMatches = new Dictionary<string, FileEntitySetting>();

            var fileExtensionElements = CurrentStaticFileHandlerConfiguration.Current.FileExtensions;
            foreach (FileExtensionElement fileExtension in fileExtensionElements)
            {
                var extensions = fileExtension.Extension.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var extension in extensions)
                {
                    var key = extension.Trim().ToLower();
                    if (!key.StartsWith("."))
                    {
                        key = "." + key;
                    }

                    var fileExtensionElement = new FileEntitySetting
                    {
                        Compress = fileExtension.Compress,
                        Extension = fileExtension.Extension,
                        MaxMemorySize = fileExtension.MaxMemorySize,
                        ServeFromMemory = fileExtension.ServeFromMemory,
                        EtagMethod = fileExtension.EtagMethod,
                        Expires = fileExtension.Expires,
                        MemorySlidingExpiration = fileExtension.MemorySlidingExpiration
                    };

                    fileExtensionMatches.Add(key, fileExtensionElement);
                }
            }

            return fileExtensionMatches;
        }
Exemple #2
0
 public FileEntity(IRetryableFileOpener retryableFileOpener, IMimeTyper mimeTyper, IHasher hasher, long maxFileSizeToServe, int bufferSize, FileInfo fileInfo, FileEntitySetting fileEntitySetting)
 {
     RetryableFileOpener = retryableFileOpener;
     MimeTyper = mimeTyper;
     Hasher = hasher;
     BufferSize = bufferSize;
     MaxFileSizeToServe = maxFileSizeToServe;
     FileInfo = fileInfo;
     FileEntitySetting = fileEntitySetting;
 }
Exemple #3
0
        public FileEntitySetting GetSetting(FileInfo fileInfo)
        {
            FileEntitySetting fileEntitySetting = null;

            if (!_fileExtensionMatches.TryGetValue(fileInfo.Extension.ToLower(), out fileEntitySetting))
            {
                fileEntitySetting = _fileEntitySettingDefault;
            }

            return(fileEntitySetting);
        }
Exemple #4
0
 public FileEntity(ICacheManager cacheManager, IRetryableFileOpener retryableFileOpener, IMimeTyper mimeTyper, IHasher hasher, long maxFileSizeToServe, int bufferSize, FileInfo fileInfo, FileEntitySetting fileEntitySetting)
 {
     CacheManager        = cacheManager;
     RetryableFileOpener = retryableFileOpener;
     MimeTyper           = mimeTyper;
     Hasher             = hasher;
     BufferSize         = bufferSize;
     MaxFileSizeToServe = maxFileSizeToServe;
     FileInfo           = fileInfo;
     FileEntitySetting  = fileEntitySetting;
 }
Exemple #5
0
        private static Dictionary <string, FileEntitySetting> GetFileExtensionsForMatches()
        {
            var fileExtensionMatches = new Dictionary <string, FileEntitySetting>();

            var fileExtensionElements = CurrentStaticFileHandlerConfiguration.Current.FileExtensions;

            foreach (FileExtensionElement fileExtension in fileExtensionElements)
            {
                var extensions = fileExtension.Extension.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var extension in extensions)
                {
                    var key = extension.Trim().ToLower();
                    if (!key.StartsWith("."))
                    {
                        key = "." + key;
                    }

                    var fileExtensionElement = new FileEntitySetting
                    {
                        Compress                = fileExtension.Compress,
                        Extension               = fileExtension.Extension,
                        MaxMemorySize           = fileExtension.MaxMemorySize,
                        ServeFromMemory         = fileExtension.ServeFromMemory,
                        EtagMethod              = fileExtension.EtagMethod,
                        Expires                 = fileExtension.Expires,
                        MemorySlidingExpiration = fileExtension.MemorySlidingExpiration,
                        UrlEtagQuerystringName  = fileExtension.UrlEtagQuerystringName,
                        UrlEtagHandlingMethod   = fileExtension.UrlEtagHandlingMethod,
                    };

                    fileExtensionMatches.Add(key, fileExtensionElement);
                }
            }

            return(fileExtensionMatches);
        }
Exemple #6
0
 public FileEntitySettingProvider()
 {
     _fileExtensionMatches     = GetFileExtensionsForMatches();
     _fileEntitySettingDefault = GetDefaultFileExtensionForNoMatches();
 }
 public FileEntitySettingProvider()
 {
     _fileExtensionMatches = GetFileExtensionsForMatches();
     _fileEntitySettingDefault = GetDefaultFileExtensionForNoMatches();
 }