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, accessedFiles);
            }

            if (result != null)
            {
                state.ReplaceContent(new ContentResult()
                {
                    Content  = result,
                    MimeType = MimeType,
                    CacheInvalidationFileList = accessedFiles,
                });
            }
        }
Esempio n. 2
0
 public override void PreExecute(ContentTransformState state)
 {
     if (state.Path.EndsWith(".min.js", StringComparison.OrdinalIgnoreCase))
     {
         state.Items.Add("Uglify", true);
         state.RemapPath(state.Path.Replace(".min.js", ".js"));
     }
 }
        public override void Execute(ContentTransformState state)
        {
            if (!state.Items.ContainsKey(StateKey))
            {
                return;
            }

            base.Execute(state);
        }
        public override void Execute(ContentTransformState state)
        {
            bool bare = false;

            if (state.Items.ContainsKey(StateKey))
            {
                bare = true;
            }

            base.Execute(state, bare);
        }
        public override void Execute(ContentTransformState state)
        {
            bool bare = false;  // Default to non-bare mode like CoffeeScript compiler

            if (state.Items.ContainsKey(StateKey))
            {
                bare = true;
            }

            base.Execute(state, bare);
        }
 public override void PreExecute(ContentTransformState state)
 {
     if (state.Path.EndsWith(".min.js", StringComparison.OrdinalIgnoreCase))
     {
         state.Items.Add(StateKey, true);
         var newPath = state.Path
                       .ToLowerInvariant()
                       .Replace(".min.js", ".js");
         state.RemapPath(newPath);
     }
     base.PreExecute(state);
 }
 public override void PreExecute(ContentTransformState state)
 {
     if (BareModeDetection.IsMatch(state.Path))
     {
         state.Items.Add(StateKey, true);
         var newPath = state.Path
                       .ToLowerInvariant()
                       .Replace(".bare.js", ".js")
                       .Replace(".bare.min.js", ".min.js");
         state.RemapPath(newPath);
     }
     base.PreExecute(state);
 }
        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);
                    }
                }
            }
        }
Esempio n. 9
0
        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,
                });
            }
        }
Esempio n. 10
0
 public override void Execute(ContentTransformState state)
 {
     Execute(state);
 }