Example #1
0
        /// <summary>
        /// 以指定的根目录为特定范围添加物理文件存储器。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="basePath">物理文件存储的根目录。</param>
        /// <param name="scopes">文件存储范围。</param>
        public static void AddPhysicalFileStorage(this IFileStorageManager manager, string basePath, params string[] scopes)
        {
            Guard.AbsolutePhysicalPath(basePath, nameof(basePath));
            var options = new PhysicalFileStorageOptions()
            {
                IncludeScopes = scopes, FileMapping = new DefaultFileRequestMapping(basePath)
            };
            PhysicalFileStorageProvider provider = new PhysicalFileStorageProvider(options);

            manager.AddProvider(provider);
        }
Example #2
0
        /// <summary>
        /// 以指定的配置添加物理文件存储器。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="options">物理文件存储配置。</param>
        public static void AddPhysicalFileStorage(this IFileStorageManager manager, PhysicalFileStorageOptions options)
        {
            Guard.ArgumentNotNull(options, nameof(options));

            if (options.FileMapping == null)
            {
                throw new ArgumentException($"必须为提供 {nameof(PhysicalFileStorageOptions)} 的非空 {nameof(PhysicalFileStorageOptions.FileMapping)} 属性。");
            }

            options = options ?? new PhysicalFileStorageOptions();
            PhysicalFileStorageProvider provider = new PhysicalFileStorageProvider(options);

            manager.AddProvider(provider);
        }
Example #3
0
 public PhysicalFileStorageProvider(PhysicalFileStorageOptions options)
 {
     Guard.ArgumentNotNull(options, nameof(options));
     this._options  = options;
     this._patterns = GetKeyPatterns();
 }