/// <summary> /// /// </summary> /// <param name="folder"></param> /// <param name="backlogSizeKB">允许内存中挤压的日志内容大小(默认为 20M)</param> public BlockingContent(string folder, int backlogSizeKB = 20 * 1024) { Guard.AbsolutePhysicalPath(folder, nameof(folder)); this.QueueOptions = new QueueOptions() { ConsumeConcurrencyLevel = 1, QueueMaxSizeKBytes = backlogSizeKB }; _folder = folder; _resetEvent = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); }
/// <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); }
public virtual string GetRelativeApplicationPath(string physicalPath, string scope) { Guard.AbsolutePhysicalPath(physicalPath, nameof(physicalPath)); string root = _rootPhysical; if (!scope.IsNullOrWhiteSpace()) { root = Path.Combine(_rootPhysical, scope); } string path = physicalPath.TrimStart(root).TrimStart(DirectorySeparator); return(path); }
public DefaultFileRequestMapping(string physicalRootFolder, String requestRootPath = "/") { Guard.AbsolutePhysicalPath(physicalRootFolder, nameof(physicalRootFolder)); Guard.ArgumentIsUri(requestRootPath, nameof(requestRootPath)); _rootUri = physicalRootFolder; if (DirectorySeparator != '/') { _rootUri = _rootUri.Replace(DirectorySeparator, '/'); } _rootUri = _rootUri.TrimEnd('/'); _rootPhysical = (DirectorySeparator != '/') ? _rootUri.Replace('/', DirectorySeparator) : _rootUri; _requestPath = requestRootPath; }
/// <summary> /// 以指定的根目录和 URL 映射程序配置物理文件存储器用作临时文件存储。 /// </summary> /// <param name="manager"></param> /// <param name="basePath">临时文件存储的根目录。</param> /// <param name="requestUrl">请求的根目录。</param> /// <param name="tempFileExpiredMinutes">临时文件过期时间(分钟)。</param> public static void UsePhysicalTemporaryFileStorage(this IFileStorageManager manager, string basePath, string requestUrl, int tempFileExpiredMinutes = 30) { Guard.AbsolutePhysicalPath(basePath, basePath); manager.UsePhysicalTemporaryFileStorage(new DefaultFileRequestMapping(basePath, requestUrl), tempFileExpiredMinutes); }
public PhysicalFileLock(string lockFilePath) { Guard.AbsolutePhysicalPath(lockFilePath, nameof(lockFilePath)); _filePath = lockFilePath; _syncRoot = new object(); }