コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptRegistrar"/> class.
        /// </summary>
        /// <param name="scripts">The scripts.</param>
        /// <param name="scriptableComponents">The scriptable components.</param>
        /// <param name="viewContext">The view context.</param>
        /// <param name="assetItemMerger">The asset merger.</param>
        /// <param name="scriptWrapper">The script wrapper.</param>
        public ScriptRegistrar(WebAssetItemCollection scripts, IList<IScriptableComponent> scriptableComponents, ViewContext viewContext, IWebAssetItemMerger assetItemMerger, ScriptWrapperBase scriptWrapper)
        {
            Guard.IsNotNull(scripts, "scripts");
            Guard.IsNotNull(scriptableComponents, "scriptableComponents");
            Guard.IsNotNull(viewContext, "viewContext");
            Guard.IsNotNull(assetItemMerger, "assetItemMerger");
            Guard.IsNotNull(scriptWrapper, "scriptWrapper");

            if (viewContext.HttpContext.Items[Key] != null)
            {
                throw new InvalidOperationException(Resources.TextResource.OnlyOneScriptRegistrarIsAllowedInASingleRequest);
            }

            viewContext.HttpContext.Items[Key] = this;

            DefaultGroup = new WebAssetItemGroup("default") { DefaultPath = FrameworkScriptPath };
            Scripts = scripts;
            this.scriptableComponents = scriptableComponents;
            ViewContext = viewContext;
            AssetMerger = assetItemMerger;
            ScriptWrapper = scriptWrapper;
            AssetHandlerPath = WebAssetHttpHandler.DefaultPath;

            OnDocumentReadyActions = new List<Action>();
            OnWindowUnloadActions = new List<Action>();
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleSheetRegistrar"/> class.
        /// </summary>
        /// <param name="styleSheets">The style sheets.</param>
        /// <param name="viewContext">The view context.</param>
        /// <param name="assetItemMerger">The asset merger.</param>
        public StyleSheetRegistrar(WebAssetItemCollection styleSheets, ViewContext viewContext, IWebAssetItemMerger assetItemMerger)
        {
            // If the instance object is null.
            if (styleSheets == null)
            {
                throw new System.ArgumentNullException("styleSheets");
            }
            if (viewContext == null)
            {
                throw new System.ArgumentNullException("viewContext");
            }
            if (assetItemMerger == null)
            {
                throw new System.ArgumentNullException("assetItemMerger");
            }

            if (viewContext.HttpContext.Items[Key] != null)
            {
                throw new InvalidOperationException("Only one style sheet registrar is allowed in a single request");
            }

            viewContext.HttpContext.Items[Key] = this;

            DefaultGroup = new WebAssetItemGroup("default", false)
            {
                DefaultPath = WebAssetDefaultSettings.StyleSheetFilesPath
            };
            StyleSheets = styleSheets;
            ViewContext = viewContext;
            AssetMerger = assetItemMerger;

            AssetHandlerPath = WebAssetHttpHandler.DefaultPath;
        }
コード例 #3
0
ファイル: ScriptRegistrar.cs プロジェクト: waffle-iron/nequeo
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptRegistrar"/> class.
        /// </summary>
        /// <param name="scripts">The scripts.</param>
        /// <param name="scriptableComponents">The scriptable components.</param>
        /// <param name="viewContext">The view context.</param>
        /// <param name="assetItemMerger">The asset merger.</param>
        /// <param name="scriptWrapper">The script wrapper.</param>
        public ScriptRegistrar(WebAssetItemCollection scripts, IList <IScriptableComponent> scriptableComponents,
                               ViewContext viewContext, IWebAssetItemMerger assetItemMerger, ScriptWrapperBase scriptWrapper)
        {
            // If the instance object is null.
            if (scripts == null)
            {
                throw new System.ArgumentNullException("scripts");
            }
            if (scriptableComponents == null)
            {
                throw new System.ArgumentNullException("scriptableComponents");
            }
            if (viewContext == null)
            {
                throw new System.ArgumentNullException("viewContext");
            }
            if (assetItemMerger == null)
            {
                throw new System.ArgumentNullException("assetItemMerger");
            }
            if (scriptWrapper == null)
            {
                throw new System.ArgumentNullException("scriptWrapper");
            }

            if (viewContext.HttpContext.Items[Key] != null)
            {
                throw new InvalidOperationException("Only one script registrar is allowed in a single request");
            }

            viewContext.HttpContext.Items[Key] = this;

            DefaultGroup = new WebAssetItemGroup("default", false)
            {
                DefaultPath = WebAssetDefaultSettings.ScriptFilesPath
            };
            Scripts = scripts;
            Scripts.Insert(0, DefaultGroup);

            this.scriptableComponents = scriptableComponents;
            ViewContext      = viewContext;
            AssetMerger      = assetItemMerger;
            ScriptWrapper    = scriptWrapper;
            AssetHandlerPath = WebAssetHttpHandler.DefaultPath;

            OnDocumentReadyActions    = new List <Action>();
            OnDocumentReadyStatements = new List <string>();
            OnWindowUnloadActions     = new List <Action>();
            OnWindowUnloadStatements  = new List <string>();
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleSheetRegistrar"/> class.
        /// </summary>
        /// <param name="styleSheets">The style sheets.</param>
        /// <param name="viewContext">The view context.</param>
        /// <param name="assetItemMerger">The asset merger.</param>
        public StyleSheetRegistrar(WebAssetItemCollection styleSheets, ViewContext viewContext, IWebAssetItemMerger assetItemMerger)
        {
            Guard.IsNotNull(styleSheets, "styleSheets");
            Guard.IsNotNull(viewContext, "viewContext");
            Guard.IsNotNull(assetItemMerger, "assetItemMerger");

            if (viewContext.HttpContext.Items[Key] != null)
            {
                throw new InvalidOperationException(Resources.TextResource.OnlyOneStyleSheetRegistrarIsAllowedInASingleRequest);
            }

            viewContext.HttpContext.Items[Key] = this;

            DefaultGroup = new WebAssetItemGroup("default", false) { DefaultPath = WebAssetDefaultSettings.StyleSheetFilesPath };
            StyleSheets = styleSheets;
            styleSheets.Insert(0, DefaultGroup);

            ViewContext = viewContext;
            AssetMerger = assetItemMerger;

            AssetHandlerPath = WebAssetHttpHandler.DefaultPath;
        }