/// <summary> /// Gets the Telerik View Component Factory /// </summary> /// <param name="helper">The helper.</param> /// <returns>The Factory</returns> public static ViewComponentFactory Telerik(this HtmlHelper helper) { Guard.IsNotNull(helper, "helper"); ViewContext viewContext = helper.ViewContext; HttpContextBase httpContext = viewContext.HttpContext; ViewComponentFactory factory = httpContext.Items[Key] as ViewComponentFactory; if (factory == null) { IWebAssetItemMerger assetItemMerger = CreateAssetMerger(viewContext); StyleSheetRegistrar styleSheetRegistrar = new StyleSheetRegistrar(new WebAssetItemCollection(WebAssetDefaultSettings.StyleSheetFilesPath), new List<IStyleableComponent>(), viewContext, assetItemMerger); ScriptRegistrar scriptRegistrar = new ScriptRegistrar(new WebAssetItemCollection(WebAssetDefaultSettings.ScriptFilesPath), new List<IScriptableComponent>(), viewContext, assetItemMerger, new ScriptWrapper()); StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new StyleSheetRegistrarBuilder(styleSheetRegistrar); ScriptRegistrarBuilder scriptRegistrarBuilder = new ScriptRegistrarBuilder(scriptRegistrar); factory = new ViewComponentFactory(styleSheetRegistrarBuilder, scriptRegistrarBuilder); helper.ViewContext.HttpContext.Items[Key] = factory; } return factory; }
/// <summary> /// Gets the Telerik View Component Factory /// </summary> /// <param name="helper">The helper.</param> /// <returns>The Factory</returns> public static ViewComponentFactory <TModel> Telerik <TModel>(this HtmlHelper <TModel> helper) { Guard.IsNotNull(helper, "helper"); ViewContext viewContext = helper.ViewContext; HttpContextBase httpContext = viewContext.HttpContext; ScriptWrapperBase scriptWrapper = DI.Current.Resolve <ScriptWrapperBase>(); IClientSideObjectWriterFactory clientSideObjectWriterFactory = DI.Current.Resolve <IClientSideObjectWriterFactory>(); StyleSheetRegistrar styleSheetRegistrar = httpContext.Items[StyleSheetRegistrar.Key] as StyleSheetRegistrar ?? new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, DI.Current.Resolve <IWebAssetCollectionResolver>()); ScriptRegistrar scriptRegistrar = httpContext.Items[ScriptRegistrar.Key] as ScriptRegistrar ?? new ScriptRegistrar(new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath), new List <IScriptableComponent>(), viewContext, DI.Current.Resolve <IWebAssetCollectionResolver>(), scriptWrapper); StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = StyleSheetRegistrarBuilder.Create(styleSheetRegistrar); ScriptRegistrarBuilder scriptRegistrarBuilder = ScriptRegistrarBuilder.Create(scriptRegistrar); return(new ViewComponentFactory <TModel>(helper, clientSideObjectWriterFactory, styleSheetRegistrarBuilder, scriptRegistrarBuilder)); }
/// <summary> /// Initializes a new instance of the <see cref="StyleSheetRegistrarBuilder"/> class. /// </summary> /// <param name="styleSheetRegistrar">The style sheet registrar.</param> public StyleSheetRegistrarBuilder(StyleSheetRegistrar styleSheetRegistrar) { Guard.IsNotNull(styleSheetRegistrar, "styleSheetRegistrar"); this.styleSheetRegistrar = styleSheetRegistrar; }