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; }
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; }
public FileEntitySetting GetSetting(FileInfo fileInfo) { FileEntitySetting fileEntitySetting = null; if (!_fileExtensionMatches.TryGetValue(fileInfo.Extension.ToLower(), out fileEntitySetting)) { fileEntitySetting = _fileEntitySettingDefault; } return(fileEntitySetting); }
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; }
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); }
public FileEntitySettingProvider() { _fileExtensionMatches = GetFileExtensionsForMatches(); _fileEntitySettingDefault = GetDefaultFileExtensionForNoMatches(); }