Exemplo n.º 1
0
 public static void RebuildAllBundles(IRequestHandler requestHandler)
 {
     foreach (FileInfo bundleFileInfo in FileSystemRepository.GetFiles(PathManager.GetBundlesPath(requestHandler), "*.json", null))
     {
         BandleManager.RebuildBundle(requestHandler, bundleFileInfo.Name);
     }
 }
Exemplo n.º 2
0
        public static void RebuildBundle(IRequestHandler requestHandler, string bundleFilename)
        {
            try
            {
                dynamic bundle     = JsonConvert.DeserializeObject(File.ReadAllText(PathManager.GetBundlePath(requestHandler, bundleFilename)));
                string  outputFile = bundle.outputFile;
                IEnumerable <string> inputFiles = bundle.inputFiles.ToObject <IEnumerable <string> >();
                string        input             = BandleManager.ConcatFiles(requestHandler, inputFiles);
                UgliflyResult result            = outputFile.EndsWith(".css") ? Uglify.Css(input) : outputFile.EndsWith(".js") ? Uglify.Js(input) : default(UgliflyResult);

                if (!result.HasErrors)
                {
                    File.WriteAllText(PathManager.GetContentRootPath(requestHandler) + "\\" + outputFile, result.Code);
                }
            }

            catch { }
        }