Ejemplo n.º 1
0
        public ScriptModel(string loaderScript, string scriptFlavor, ScriptInliner scriptInliner)
        {
            _loaderScript  = loaderScript;
            _scriptFlavor  = scriptFlavor;
            _scriptInliner = scriptInliner;

            _references   = new List <ScriptReference>();
            _referenceMap = new Dictionary <string, ScriptReference>();
        }
Ejemplo n.º 2
0
        public ScriptModel(string loaderScript, string scriptFlavor, ScriptInliner scriptInliner)
        {
            _loaderScript = loaderScript;
            _scriptFlavor = scriptFlavor;
            _scriptInliner = scriptInliner;

            _references = new List<ScriptReference>();
            _referenceMap = new Dictionary<string, ScriptReference>();
        }
Ejemplo n.º 3
0
        public static void InitializeScripts(this AjaxHelper ajaxHelper, string scriptFlavor, bool enableInlining)
        {
            if (ajaxHelper == null) {
                throw new ArgumentNullException("ajaxHelper");
            }

            HttpContextBase httpContext = ajaxHelper.ViewContext.HttpContext;

            if (httpContext.Items[typeof(ScriptModel)] != null) {
                throw new InvalidOperationException("You must call InitializeScripts only once.");
            }

            ScriptSharpSection configSection = ScriptSharpSection.GetSettings();
            ScriptElement coreScriptElement = configSection.Scripts.GetElement(LoaderScriptName, scriptFlavor);

            ScriptInliner scriptInliner = null;
            if (enableInlining) {
                string storageCookieName = configSection.ClientScriptStorageCookie;
                if (String.IsNullOrEmpty(storageCookieName) == false) {
                    scriptInliner = new ScriptInliner(httpContext, storageCookieName);
                }
            }

            ScriptModel scriptModel = new ScriptModel(coreScriptElement.Url, scriptFlavor, scriptInliner);
            httpContext.Items[typeof(ScriptModel)] = scriptModel;
        }