private static string ReadResourceContent(Resource resource, bool useCache) { if (Log.IsDebugEnabled) { Log.Debug("Reading content of " + resource.Path + "..."); } return(useCache ? resource.ReadFromCache(true) : resource.ReadNewContent()); }
/// <summary> /// Loads the content of the resource from the cache. Otherwise, /// reload the content from its source (e.g. file system or HTTP download) /// and store it in the cache for subsequent accesses. /// </summary> /// <param name="resource">The resource whose cached content is to be retrieved.</param> /// <param name="readNewIfEmptyCache">If true, attempt to read the content from the orginal source (file system or HTTP) /// when the cached content isn't found. If false, not attempting to do so.</param> /// <returns>The cached content of the resource. If not found and <paramref name="readNewIfEmptyCache"/> is true, return /// the content from source. Otherwise, return null.</returns> public static string ReadFromCache(this Resource resource, bool readNewIfEmptyCache) { var content = Cache.Get(resource); if (content != null) { if (Log.IsDebugEnabled) { Log.Debug("Use content from content's cache for " + resource); } return(content); } return(readNewIfEmptyCache ? resource.ReadNewContent() : null); }