public CFileSource(string filePath, IFileSystemAsync fs) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentNullException("Source path is null or empty."); } _fs = fs; FilePath = filePath; }
public CFileSource(Stream stream, bool leaveOpen, IFileSystemAsync fs) { if (stream == null) { throw new ArgumentNullException("Stream is null."); } _leaveOpen = leaveOpen; _fs = fs; Stream = stream; }
/// <summary> /// File cache default ctr. /// </summary> /// <param name="baseFolder">Folder in which this instance of file cache will reside.</param> /// <param name="fileSystem">File system interface to use in all file operation. Defaul is current file system.</param> /// <param name="disableGc">Check if you will manage garbage collection yourself.</param> public FileCacheAsync(string baseFolder, IFileSystemAsync fileSystem = null, bool disableGc = false) { if (baseFolder == null) { throw new ArgumentNullException(nameof(baseFolder)); } _perKeyLock = new PerKeySemaphoreSlim(); _cacheLock = new AsyncReaderWriterLock(); _fs = fileSystem ?? FileSystemAsync.Instance; _baseFolder = baseFolder; _invalid = true; if (!disableGc) { _cts = new CancellationTokenSource(); _gc = GcTask(_cts.Token); } }