public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { if (virtualPathDependencies == null) { return(null); } StringCollection physicalDependencies = null; // Get the list of physical dependencies foreach (string virtualDependency in virtualPathDependencies) { string physicalDependency = HostingEnvironment.MapPathInternal(virtualDependency); if (physicalDependencies == null) { physicalDependencies = new StringCollection(); } physicalDependencies.Add(physicalDependency); } if (physicalDependencies == null) { return(null); } // Copy the list of physical dependencies into an array string[] physicalDependenciesArray = new string[physicalDependencies.Count]; physicalDependencies.CopyTo(physicalDependenciesArray, 0); return(new CacheDependency(0, physicalDependenciesArray, utcStart)); }
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { if (virtualPathDependencies == null) { return(null); } StringCollection strings = null; foreach (string str in virtualPathDependencies) { string str2 = HostingEnvironment.MapPathInternal(str); if (strings == null) { strings = new StringCollection(); } strings.Add(str2); } if (strings == null) { return(null); } string[] array = new string[strings.Count]; strings.CopyTo(array, 0); return(new CacheDependency(0, array, utcStart)); }
private bool CacheLookupOrInsert(string virtualPath, bool isFile) { string physicalPath = HostingEnvironment.MapPathInternal(virtualPath); bool doNotCacheUrlMetadata = CachedPathData.DoNotCacheUrlMetadata; string key = null; if (!doNotCacheUrlMetadata) { key = this.CreateCacheKey(isFile, physicalPath); bool?nullable = HttpRuntime.CacheInternal[key] as bool?; if (nullable.HasValue) { return(nullable.Value); } } bool flag2 = isFile ? File.Exists(physicalPath) : Directory.Exists(physicalPath); if (!doNotCacheUrlMetadata) { CacheDependency dependencies = null; string filename = flag2 ? physicalPath : FileUtil.GetFirstExistingDirectory(AppRoot, physicalPath); if (filename != null) { dependencies = new CacheDependency(filename); TimeSpan urlMetadataSlidingExpiration = CachedPathData.UrlMetadataSlidingExpiration; HttpRuntime.CacheInternal.UtcInsert(key, flag2, dependencies, Cache.NoAbsoluteExpiration, urlMetadataSlidingExpiration); } } return(flag2); }
private void EnsureFileInfoObtained() { if (this._physicalPath == null) { this._physicalPath = HostingEnvironment.MapPathInternal(base.VirtualPath); FindFileData.FindFile(this._physicalPath, out this._ffd); } }
private void EnsureFileInfoObtained() { // Get the physical path and FindFileData on demand if (_physicalPath == null) { Debug.Assert(_ffd == null); _physicalPath = HostingEnvironment.MapPathInternal(VirtualPath); FindFileData.FindFile(_physicalPath, out _ffd); } }
public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies) { HashCodeCombiner combiner = new HashCodeCombiner(); foreach (string str in virtualPathDependencies) { string fileName = HostingEnvironment.MapPathInternal(str); combiner.AddFile(fileName); } return(combiner.CombinedHashString); }
public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies) { HashCodeCombiner hashCodeCombiner = new HashCodeCombiner(); // Calculate the hash based on the time stamps of all the virtual paths foreach (string virtualDependency in virtualPathDependencies) { string physicalDependency = HostingEnvironment.MapPathInternal(virtualDependency); hashCodeCombiner.AddFile(physicalDependency); } return(hashCodeCombiner.CombinedHashString); }
private bool CacheLookupOrInsert(string virtualPath, bool isFile) { string physicalPath = HostingEnvironment.MapPathInternal(virtualPath); bool doNotCache = CachedPathData.DoNotCacheUrlMetadata; string cacheKey = null; if (!doNotCache) { cacheKey = CreateCacheKey(isFile, physicalPath); // tri-state: // * null means it's not cached // * true means it's cached and it exists // * false means it's cached and it doesn't exist bool?cacheValue = HttpRuntime.Cache.InternalCache.Get(cacheKey) as bool?; if (cacheValue != null) { return(cacheValue.Value); } } bool exists = (isFile) ? File.Exists(physicalPath) : Directory.Exists(physicalPath); if (doNotCache) { return(exists); } // Setup a cache entry for this so we don't hit the file system every time CacheDependency dep = null; // Code based on similar logic from FileAuthorizationModule. // If file does not exist, but it's path is beneath the app root, we will cache it and // use the first existing directory as the cache depenedency path. If it does not exist // and it's not beneath the app root, we cannot cache it. string existingDir = (exists) ? physicalPath : FileUtil.GetFirstExistingDirectory(AppRoot, physicalPath); if (existingDir != null) { dep = new CacheDependency(existingDir); TimeSpan slidingExp = CachedPathData.UrlMetadataSlidingExpiration; HttpRuntime.Cache.InternalCache.Insert(cacheKey, exists, new CacheInsertOptions() { Dependencies = dep, SlidingExpiration = slidingExp }); } return(exists); }
public override string MapPath(string path) { return(HostingEnvironment.MapPathInternal(path)); }