public void Init(HttpApplication context) { var coffeeEngine = new CoffeeScriptCompiler(); var compilers = new ISimpleFileCompiler[] { new ConcatenationFileHandler(this), new MinifyingFileCompiler(coffeeEngine), new CoffeeScriptFileCompiler(coffeeEngine), new SassFileCompiler(), new JavascriptPassthroughCompiler(), }; _handlers = new Dictionary<ISimpleFileCompiler, IHttpHandler>(); foreach (var compiler in compilers) { compiler.Init(context); _handlers[compiler] = new CompilableFileHandler(compiler); } context.PostResolveRequestCache += (o, e) => { var app = o as HttpApplication; var compiler = MapPathToCompiler(app.Request.PhysicalPath); if (compiler == null) { return; } app.Context.RemapHandler(_handlers[compiler]); }; }
public void Init(HttpApplication context) { var compilers = new ISimpleFileCompiler[] { new CoffeeScriptFileCompiler(), new SassFileCompiler(), }; _handlers = new Dictionary<string, IHttpHandler>(); foreach (var compiler in compilers) { compiler.Init(context); _handlers[compiler.OutputFileExtension] = new CompilableFileHandler(compiler); } context.PostResolveRequestCache += (o, e) => { var app = o as HttpApplication; string ext = Path.GetExtension(app.Request.PhysicalPath.ToLowerInvariant()); if (!_handlers.ContainsKey(ext)) { return; } app.Context.RemapHandler(_handlers[ext]); }; }
public CompilableFileHandler(ISimpleFileCompiler compiler) { _compiler = compiler; }
private CompilationResult CompileContent(string physicalFileName, ISimpleFileCompiler compiler) { var fi = new FileInfo(physicalFileName); return new CompilationResult(true, compiler.ProcessFileContent(physicalFileName), compiler.OutputMimeType, fi.LastWriteTimeUtc); }
private string GetCacheKey(string physicalFileName, ISimpleFileCompiler compiler) { var fi = new FileInfo(physicalFileName); var token = compiler.GetFileChangeToken(physicalFileName) ?? String.Empty; return String.Format("{0:yyyyMMddHHmmss}-{1}-{2}{3}", fi.LastWriteTimeUtc, token, Path.GetFileNameWithoutExtension(physicalFileName), compiler.OutputFileExtension); }
protected SassAndCoffeeHandler(ISimpleFileCompiler simpleFileCompiler) { this.simpleFileCompiler = simpleFileCompiler; }
protected SassAndCoffeeHandler(ISimpleFileCompiler simpleFileCompiler) { this.simpleFileCompiler = simpleFileCompiler; }
private CompilationResult CompileContent(ICompilerFile physicalFileName, ISimpleFileCompiler compiler) { return new CompilationResult(true, compiler.ProcessFileContent(physicalFileName), compiler.OutputMimeType, physicalFileName.LastWriteTimeUtc); }