Exemplo n.º 1
0
        public static string GetBundlesPath(IRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(PathManager.bundlesPath))
            {
                PathManager.bundlesPath = PathManager.GetContentRootPath(requestHandler) + "\\Bundles";
            }

            return(PathManager.bundlesPath);
        }
Exemplo n.º 2
0
        public static string GetScriptsPath(IRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(PathManager.scriptsPath))
            {
                PathManager.scriptsPath = Path.Combine(PathManager.GetContentRootPath(requestHandler), "Scripts");
            }

            return(PathManager.scriptsPath);
        }
Exemplo n.º 3
0
        public static string GetBundlesPath(IRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(PathManager.bundlesPath))
            {
                PathManager.bundlesPath = PathManager.Combine(PathManager.GetContentRootPath(requestHandler), "Bundles");
            }

            PathManager.EnsurePathExists(PathManager.bundlesPath);
            return(PathManager.bundlesPath);
        }
Exemplo n.º 4
0
        private static string ConcatFiles(IRequestHandler requestHandler, IEnumerable <string> files)
        {
            StringBuilder result = new StringBuilder();

            foreach (string file in files)
            {
                result.AppendLine(File.ReadAllText(PathManager.Combine(PathManager.GetContentRootPath(requestHandler), file)));
            }

            return(result.ToString());
        }
Exemplo n.º 5
0
        public static string GetViewsPath(IRequestHandler requestHandler, string subdirectory)
        {
            if (string.IsNullOrEmpty(PathManager.viewsPath))
            {
                PathManager.viewsPath = PathManager.GetContentRootPath(requestHandler) + "\\Views";
            }

            if (string.IsNullOrEmpty(subdirectory))
            {
                return(PathManager.viewsPath);
            }

            return(PathManager.viewsPath + "\\" + subdirectory);
        }
Exemplo n.º 6
0
        public static string GetViewsPath(IRequestHandler requestHandler, string subdirectory)
        {
            if (string.IsNullOrEmpty(PathManager.viewsPath))
            {
                PathManager.viewsPath = Path.Combine(PathManager.GetContentRootPath(requestHandler), "Views");
            }

            if (string.IsNullOrEmpty(subdirectory))
            {
                return(PathManager.viewsPath);
            }

            return(Path.Combine(PathManager.viewsPath, subdirectory));
        }
Exemplo n.º 7
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);
                UglifyResult result = outputFile.EndsWith(".css") ? Uglify.Css(input) : outputFile.EndsWith(".js") ? Uglify.Js(input) : default(UglifyResult);

                if (!result.HasErrors)
                {
                    File.WriteAllText(Path.Combine(PathManager.GetContentRootPath(requestHandler), outputFile), result.Code);
                }
            }

            catch { }
        }