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) { // 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; string newPath = null; if (trimmed.StartsWith("~/") && trimmed.Length > 2 && _appRootPath != null) { // ASP.Net absolute path newPath = _appRootPath + trimmed.Substring(2); } else { // Relative path 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) { if (!state.Items.ContainsKey(StateKey)) return; base.Execute(state); }
public override void PreExecute(ContentTransformState state) { if (state.Path.EndsWith(".min.css", StringComparison.OrdinalIgnoreCase)) { state.Items.Add(CompressedStateKey, true); var newPath = state.Path .ToLowerInvariant() .Replace(".min.css", ".css"); state.RemapPath(newPath); } base.PreExecute(state); }
protected virtual void Execute(ContentTransformState state, params object[] args) { // 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, args); } if (result != null) { state.ReplaceContent(new ContentResult() { Content = result, MimeType = OutputMimeType, }); } }
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, 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; } // 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) { // Support 404, not just 500 if (state.RootPath == null) return; var fileSource = FindFileFromRoot(state.RootPath); if (fileSource == null) return; string result = null; var accessedFiles = new List<string>(); using (var compiler = _compilerPool.GetInstance()) { result = compiler.Compile(fileSource, state.Items.ContainsKey(CompressedStateKey), accessedFiles); } if (result != null) { state.ReplaceContent(new ContentResult() { Content = result, MimeType = MimeType, CacheInvalidationFileList = accessedFiles, }); } }
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, MimeType = state.MimeType, }; // TODO: Save in cache } return result; }
public virtual void PreExecute(ContentTransformState state) { }
public abstract void Execute(ContentTransformState state);
public override void Execute(ContentTransformState state) { Execute(state); }