public ContentResult ProcessRequest(string physicalPath) { ContentResult result = null; // TODO: Check cache // result = GetFromCache if (result == null) // Cache miss { var state = new ContentTransformState(this, physicalPath); // Pre-Execute foreach (var transform in _transformations) { transform.PreExecute(state); } // Execute foreach (var transform in _transformations) { transform.Execute(state); } if (state.Content == null) { // No source content found return(null); } result = new ContentResult() { CacheInvalidationFileList = state.CacheInvalidationFileList, Content = state.Content, MaxAgeSeconds = state.MaxAgeSeconds, MimeType = state.MimeType, }; // TODO: Save in cache } return(result); }
public override void Execute(ContentTransformState state) { // We're a content provider. If content is already set, do nothing. if (state.Content != null) { return; } // Support 404, not just 500 if (state.RootPath == null) { return; } var fileInfo = new FileInfo(state.RootPath + ".combine"); if (fileInfo.Exists) { state.AddCacheInvalidationFiles(new string[] { fileInfo.FullName }); var lines = File.ReadLines(fileInfo.FullName); foreach (var line in lines) { var trimmed = line.Trim(); if (string.IsNullOrEmpty(trimmed) || trimmed.StartsWith("#")) { continue; } var newPath = Path.Combine(fileInfo.DirectoryName, trimmed); var newContent = state.Pipeline.ProcessRequest(newPath); if (newContent != null) { newContent.Content += ";"; state.AppendContent(newContent); } } } }
public override void Execute(ContentTransformState state) { // We're a content provider. If content is already set, do nothing. if (state.Content != null) { return; } // Support 404, not just 500 if (state.RootPath == null) { return; } // Search for file to use as content, stop at first string content = null; string fileName = null; foreach (var extension in _extensions) { fileName = state.RootPath + extension; if (File.Exists(fileName)) { content = File.ReadAllText(fileName); break; } } if (content != null) { state.AppendContent(new ContentResult() { Content = content, MimeType = _mimeType, CacheInvalidationFileList = new string[] { fileName }, }); } }
public override void Execute(ContentTransformState state) { // If input is empty or the wrong type, do nothing if (state.Content == null || state.MimeType != InputMimeType) { return; } string result = null; using (var compiler = _jsCompilerProvider.GetInstance()) { result = compiler.Compile(state.Content); } if (result != null) { state.ReplaceContent(new ContentResult() { Content = result, MimeType = OutputMimeType, }); } }
public abstract void Execute(ContentTransformState state);
public virtual void PreExecute(ContentTransformState state) { }