コード例 #1
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
                    };

                    fileExtensionMatches.Add(key, fileExtensionElement);
                }
            }

            return fileExtensionMatches;
        }
コード例 #2
0
ファイル: FileEntity.cs プロジェクト: abedon/talifun-web
 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;
 }
コード例 #3
0
        public FileEntitySetting GetSetting(FileInfo fileInfo)
        {
            FileEntitySetting fileEntitySetting = null;

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

            return(fileEntitySetting);
        }
コード例 #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;
 }
コード例 #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);
        }
コード例 #6
0
 public FileEntitySettingProvider()
 {
     _fileExtensionMatches     = GetFileExtensionsForMatches();
     _fileEntitySettingDefault = GetDefaultFileExtensionForNoMatches();
 }
コード例 #7
0
 public FileEntitySettingProvider()
 {
     _fileExtensionMatches = GetFileExtensionsForMatches();
     _fileEntitySettingDefault = GetDefaultFileExtensionForNoMatches();
 }