private CacheFile(string path, TimeSpan?timeout, CacheFileRequestCallback requestCallback, CacheFileUpdateCallback updateCallback) { Path = path; Timeout = timeout; RequestCallback = requestCallback; UpdateCallback = updateCallback; }
/// <summary> /// Creates a new <see cref="CacheFile" /> instance for the file specified by <paramref name="path" />. If the file does not exist, yet, it is created upon first access. /// </summary> /// <param name="path">A <see cref="string" /> that contains the name of the file that represents the cached version. This file does not need to exist.</param> /// <param name="timeout">A <see cref="TimeSpan" /> value that specifies the timeout period after which the file will be updated. This value is compared to the LastWriteTime property of the file.</param> /// <param name="updateCallback">The method that is called when the file needs to be updated.</param> /// <returns> /// The <see cref="CacheFile" /> this method creates. /// </returns> public static CacheFile CreateWithTimeout(string path, TimeSpan timeout, CacheFileUpdateCallback updateCallback) { Check.ArgumentNull(path, nameof(path)); Check.ArgumentEx.StringNotEmpty(path, nameof(path)); Check.ArgumentNull(updateCallback, nameof(updateCallback)); return(new CacheFile(path, timeout, null, updateCallback)); }
/// <summary> /// Creates a new <see cref="CacheFile" /> instance for the file specified by <paramref name="path" />. If the file does not exist, yet, it is created upon first access. /// </summary> /// <param name="path">A <see cref="string" /> that contains the name of the file that represents the cached version. This file does not need to exist.</param> /// <param name="requestCallback">The method that is called when the file is accessed. If the method returns <see langword="false" />, it means the cached file is invalid and <paramref name="updateCallback" /> is called to update the file. If it returns <see langword="true" />, the existing file is read from the disk. This method is only called when the file on the disk exists.</param> /// <param name="updateCallback">The method that is called when the file needs to be updated.</param> /// <returns> /// The <see cref="CacheFile" /> this method creates. /// </returns> public static CacheFile CreateWithCallback(string path, CacheFileRequestCallback requestCallback, CacheFileUpdateCallback updateCallback) { Check.ArgumentNull(path, nameof(path)); Check.ArgumentEx.StringNotEmpty(path, nameof(path)); Check.ArgumentNull(requestCallback, nameof(requestCallback)); Check.ArgumentNull(updateCallback, nameof(updateCallback)); return(new CacheFile(path, null, requestCallback, updateCallback)); }