internal static CacheDependency GetCacheDependency(VirtualPath virtualPath) { VirtualPathProvider vpathProvider = HostingEnvironment.VirtualPathProvider; return(vpathProvider.GetCacheDependency(virtualPath, new SingleObjectCollection(virtualPath.VirtualPathString), DateTime.MaxValue)); }
public virtual CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { if (prev != null) { return(prev.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)); } return(null); }
/* * Asks the provider for a CacheDependency that will be invalidated if any of the * input files become invalid. * utcStart contains the time (UTC) at which the files were read. Any change to the file * made after that time (even if the change is in the past) should invalidate the * CacheDependency. * If the provider doesn't support using a CacheDependency, it should return null, * or simply not override GetCacheDependency (the base implementation returns null). */ public virtual CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { // Delegate to the previous VirtualPathProvider, if any if (_previous == null) { return(null); } return(_previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart)); }
/// <summary> /// 创建指定虚拟路径文件的缓存依赖项,当文件发生变化时可以清除缓存。 /// </summary> /// <param name="provider">当前所使用的虚拟路径提供程序</param> /// <param name="virtualPath">需要监视的文件虚拟路径</param> /// <returns>监视路径的缓存依赖项</returns> public static CacheDependency CreateCacheDependency( VirtualPathProvider provider, string virtualPath ) { var now = DateTime.UtcNow; return provider.GetCacheDependency( virtualPath, new[] { virtualPath }, now ) ?? new CacheDependency( HostingEnvironment.MapPath( virtualPath ) ); }