Beispiel #1
0
        /// <exclude />
        public ScriptLoader(string type, string directive = null, bool updateManagerDisabled = false)
        {
            _ctx  = HttpContext.Current;
            _type = type;
            _updateManagerDisabled = updateManagerDisabled;

            if (directive == "compile")
            {
                _mode = CompositeScriptMode.COMPILE;
            }
            else if (CookieHandler.Get("mode") == "develop")
            {
                _mode = CompositeScriptMode.DEVELOP;
            }
            else
            {
                _mode = CompositeScriptMode.OPERATE;
            }

            string folderPath = Path.Combine(_ctx.Request.PhysicalApplicationPath, "Composite");

            switch (type)
            {
            case "top":
                _defaultscripts = ScriptHandler.GetTopScripts(_mode, folderPath);

                break;

            case "sub":
                _defaultscripts = ScriptHandler.GetSubScripts(_mode, folderPath);
                break;
            }
        }
Beispiel #2
0
        private void CompileScript(StringBuilder writer)
        {
            try
            {
                string folderPath = Path.Combine(_ctx.Request.PhysicalApplicationPath, "Composite");

                string targetPath = folderPath + "\\scripts\\compressed";


                ScriptHandler.MergeScripts(_type, _defaultscripts, folderPath, targetPath);
                if (_type == "top")
                {
                    ScriptHandler.BuildTopLevelClassNames(_defaultscripts, folderPath, targetPath);
                }
            }
            catch (Exception e)
            {
                Log.LogError(typeof(ScriptLoader).FullName, new InvalidOperationException("Failed to compile scripts", e));

                writer.Append("<p> Failed to compile scripts. Exception text:");
                writer.Append(HttpUtility.HtmlEncode(e.ToString()));
                writer.Append("</p>");
            }
        }