Skip to content

Instantly share code, notes, and snippets.

@emiaj
Created March 20, 2012 22:02
Show Gist options
  • Select an option

  • Save emiaj/2141737 to your computer and use it in GitHub Desktop.

Select an option

Save emiaj/2141737 to your computer and use it in GitHub Desktop.
public class MyOwnPolicy : IAssetPolicy
{
private readonly IAssetTagPlanCache _planCache;
private readonly IAssetDependencyFinder _finder;
public MyOwnPolicy(IAssetTagPlanCache planCache, IAssetDependencyFinder finder)
{
_planCache = planCache;
_finder = finder;
}
public void Apply(IPackageLog log, IAssetPipeline pipeline, AssetGraph graph)
{
WarmUp(new[]{"pageX-styles","a-single-style.css","other-style-set-for-pageX"});
WarmUp(new[]{"pageX-scripts","a-single-script.js","other-script-set-for-pageX"});
}
public void WarmUp(string[] names)
{
var dependencies = _finder.CompileDependenciesAndOrder(names).ToList();
if (dependencies.Count == 0)
{
return;
}
var mimeType = MimeType.MimeTypeByFileName(dependencies[0]);
_planCache.PlanFor(mimeType, dependencies);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment