/// <summary> /// Returns virtual paths of included files in <paramref name="virtualPath" /> file, according to /// <paramref name="context" />. /// If not added yet and <see cref="LessTransform" /> included in bundle transforms, executes /// <see cref="LessTransform" /> transformation for the specified <paramref name="bundle" /> /// and ensures the dependencies are saved. /// </summary> /// <param name="bundle">Bundle to process, if not yet</param> /// <param name="virtualPath">Root file to get dependencies for.</param> /// <param name="context">Current context.</param> /// <returns>Virtual paths of included files.</returns> private static IEnumerable <string> GetFileDependencies(Bundle bundle, string virtualPath, BundleContext context) { string key = BundleTable.VirtualPathProvider.GetCacheKey(virtualPath) ?? virtualPath; Func <string, IList <string> > process; if (bundle.Transforms.Any(transform => transform is LessTransform)) { process = s => { IEnumerable <BundleFile> files = bundle.EnumerateFiles(context); LessTransform.Process(ref files); return(files.Select(file => file.IncludedVirtualPath).ToArray()); }; } else { process = s => new string[0]; } _fileDependencies.GetOrAdd(key, process); // returns more specific dependencies by the key containing transient file paths return(_fileDependencies.GetOrAdd(GetTransientFileKey(virtualPath), process)); }
/// <summary> /// Returns cache key for <paramref name="bundle" />. /// </summary> /// <param name="bundle"><see cref="Bundle" /> to get cache for.</param> /// <param name="context">Current <see cref="BundleContext" /></param> /// <returns>Cache key string.</returns> internal static string GetTransientBundleFilesKey(this Bundle bundle, BundleContext context) { return(ComposeTransientFilesKey(bundle .EnumerateFiles(context) .SelectMany(file => new[] { file.IncludedVirtualPath }.Concat( GetFileDependencies(bundle, file.IncludedVirtualPath, context))))); }