/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="scriptRegistrar">The script registrar.</param> public ScriptRegistrarBuilder(ScriptRegistrar scriptRegistrar) { // If the instance object is null. if (scriptRegistrar == null) { throw new System.ArgumentNullException("scriptRegistrar"); } _scriptRegistrar = scriptRegistrar; }
/// <summary> /// Gets the Component Factory for the extended UI. /// </summary> /// <param name="helper">The MVC html helper to extend.</param> /// <returns>The compoent factory reference for each UI.</returns> public static Extended.ComponentFactory NequeoUI(this HtmlHelper helper) { // If the instance object is null. if (helper == null) { throw new System.ArgumentNullException("helper"); } ViewContext viewContext = helper.ViewContext; HttpContextBase httpContext = viewContext.HttpContext; Extended.ComponentFactory factory = httpContext.Items[KeyExtended] as Extended.ComponentFactory; if (factory == null) { // Get the current service locator singleton instance. Nequeo.Runtime.IServiceLocator locator = Extended.Factory.Runtime.ServiceLocator.Current; Extended.Factory.Runtime.ServiceLocator.Register(locator); // Collect information on the current page // including all style sheets and scripts // that may already be added, do not add these // style sheets or scripts if already present. Extended.WebAsset.IWebAssetItemMerger assetItemMerger = locator.Resolve <Extended.WebAsset.IWebAssetItemMerger>(); Extended.UI.ScriptWrapperBase scriptWrapper = locator.Resolve <Extended.UI.ScriptWrapperBase>(); Extended.Factory.IClientSideObjectWriterFactory clientSideObjectWriterFactory = locator.Resolve <Extended.Factory.IClientSideObjectWriterFactory>(); Extended.UI.StyleSheetRegistrar styleSheetRegistrar = new Extended.UI.StyleSheetRegistrar( new Extended.WebAsset.WebAssetItemCollection(Extended.WebAsset.WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, assetItemMerger); Extended.UI.ScriptRegistrar scriptRegistrar = new Extended.UI.ScriptRegistrar( new Extended.WebAsset.WebAssetItemCollection(Extended.WebAsset.WebAssetDefaultSettings.ScriptFilesPath), new List <Extended.Factory.IScriptableComponent>(), viewContext, assetItemMerger, scriptWrapper); Extended.UI.StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new Extended.UI.StyleSheetRegistrarBuilder(styleSheetRegistrar); Extended.UI.ScriptRegistrarBuilder scriptRegistrarBuilder = new Extended.UI.ScriptRegistrarBuilder(scriptRegistrar); // Execute the component factory. factory = new Extended.ComponentFactory(helper, clientSideObjectWriterFactory, styleSheetRegistrarBuilder, scriptRegistrarBuilder); helper.ViewContext.HttpContext.Items[KeyExtended] = factory; } // Return the compoent factory instance. return(factory); }