public override VirtualFile GetFile(string virtualPath) { if (ThemeHelper.PathIsThemeVars(virtualPath)) { var theme = ThemeHelper.ResolveCurrentTheme(); int storeId = ThemeHelper.ResolveCurrentSiteId(); return(new ThemeVarsVirtualFile(virtualPath, theme.ThemeName, storeId)); } var result = GetResolveResult(virtualPath); if (result != null) { if (!result.IsExplicit) { return(new InheritedVirtualThemeFile(result)); } else { virtualPath = result.OriginalVirtualPath; } } return(_previous.GetFile(virtualPath)); }
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { bool isLess; bool isBundle; if (!ThemeHelper.IsStyleSheet(virtualPath, out isLess, out isBundle)) { return(GetCacheDependencyInternal(virtualPath, virtualPathDependencies, utcStart)); } else { if (!isLess && !isBundle) { // it's a static css file (no bundle, no less) return(GetCacheDependencyInternal(virtualPath, virtualPathDependencies, utcStart)); } var arrPathDependencies = virtualPathDependencies.Cast <string>().ToArray(); // determine the virtual themevars.less import reference var themeVarsFile = arrPathDependencies.Where(x => ThemeHelper.PathIsThemeVars(x)).FirstOrDefault(); if (themeVarsFile.IsEmpty()) { // no themevars import... so no special considerations here return(GetCacheDependencyInternal(virtualPath, virtualPathDependencies, utcStart)); } // exclude the themevars import from the file dependencies list, // 'cause this one cannot be monitored by the physical file system var fileDependencies = arrPathDependencies.Except(new string[] { themeVarsFile }); if (arrPathDependencies.Any()) { int storeId = ThemeHelper.ResolveCurrentSiteId(); var theme = ThemeHelper.ResolveCurrentTheme(); // invalidate the cache when variables change string cacheKey = AspNetCache.BuildKey(ModelCacheEventConsumer.BuildThemeVarsCacheKey(theme.ThemeName, storeId)); var cacheDependency = new CacheDependency(MapDependencyPaths(fileDependencies), new string[] { cacheKey }, utcStart); return(cacheDependency); } return(null); } }