Example #1
0
 private CacheFile(string path, TimeSpan?timeout, CacheFileRequestCallback requestCallback, CacheFileUpdateCallback updateCallback)
 {
     Path            = path;
     Timeout         = timeout;
     RequestCallback = requestCallback;
     UpdateCallback  = updateCallback;
 }
Example #2
0
        /// <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));
        }