/// <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(WebAssetCollection scripts, IList<IScriptableComponent> scriptableComponents, ViewContext viewContext, IWebAssetCollectionResolver resolver, ScriptWrapperBase scriptWrapper) { this.resolver = resolver; if (viewContext.HttpContext.Items[Key] != null) { throw new InvalidOperationException(Resources.TextResource.OnlyOneScriptRegistrarIsAllowedInASingleRequest); } viewContext.HttpContext.Items[Key] = this; OutputScriptFiles = true; DefaultGroup = new WebAssetGroup("default", false) { DefaultPath = WebAssetDefaultSettings.ScriptFilesPath }; Scripts = scripts; Scripts.Insert(0, DefaultGroup); this.scriptableComponents = scriptableComponents; ViewContext = viewContext; ScriptWrapper = scriptWrapper; AssetHandlerPath = WebAssetHttpHandler.DefaultPath; OnDocumentReadyActions = new List<Action>(); OnDocumentReadyStatements = new List<string>(); OnWindowUnloadActions = new List<Action>(); OnWindowUnloadStatements = new List<string>(); }
/// <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(WebAssetCollection scripts, IList <IScriptableComponent> scriptableComponents, ViewContext viewContext, IWebAssetCollectionResolver resolver, ScriptWrapperBase scriptWrapper) { this.resolver = resolver; if (viewContext.HttpContext.Items[Key] != null) { throw new InvalidOperationException(Resources.TextResource.OnlyOneScriptRegistrarIsAllowedInASingleRequest); } viewContext.HttpContext.Items[Key] = this; OutputScriptFiles = true; DefaultGroup = new WebAssetGroup("default", false) { DefaultPath = WebAssetDefaultSettings.ScriptFilesPath }; Scripts = scripts; Scripts.Insert(0, DefaultGroup); this.scriptableComponents = scriptableComponents; ViewContext = viewContext; ScriptWrapper = scriptWrapper; AssetHandlerPath = WebAssetHttpHandler.DefaultPath; OnDocumentReadyActions = new List <Action>(); OnDocumentReadyStatements = new List <string>(); OnWindowUnloadActions = new List <Action>(); OnWindowUnloadStatements = new List <string>(); }
/// <summary> /// Initializes a new instance of the <see cref="WebAssetCollectionBuilder"/> class. /// </summary> /// <param name="assetType">Type of the asset.</param> /// <param name="assets">The assets.</param> public WebAssetCollectionBuilder(WebAssetType assetType, WebAssetCollection assets) { if (assetType == WebAssetType.None) { throw new ArgumentException(TextResource.NoneIsOnlyUsedForInternalPurpose, "assetType"); } Guard.IsNotNull(assets, "assets"); this.assetType = assetType; this.assets = assets; }
public StyleSheetRegistrarTests() { _httpContext = TestHelper.CreateMockedHttpContext(); _styleSheets = new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath); _viewContext = new ViewContext { HttpContext = _httpContext.Object, ViewData = new ViewDataDictionary() }; _styleSheetRegistrar = new StyleSheetRegistrar(_styleSheets, _viewContext, new Mock <IWebAssetCollectionResolver>().Object); }
public IEnumerable<string> Resolve(ResolverContext resolverContext, WebAssetCollection assets) { var resolvedUrls = new List<string>(); foreach (var asset in assets) { resolvedUrls.AddRange(resolverFactory.Create(asset).Resolve(resolverContext)); } return resolvedUrls .Distinct(StringComparer.OrdinalIgnoreCase) .Select((url) => urlResolver.Resolve(url)); }
public StyleSheetRegistrarTests() { _httpContext = TestHelper.CreateMockedHttpContext(); _styleSheets = new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath); _viewContext = new ViewContext { HttpContext = _httpContext.Object, ViewData = new ViewDataDictionary() }; _styleSheetRegistrar = new StyleSheetRegistrar(_styleSheets, _viewContext, new Mock<IWebAssetCollectionResolver>().Object); }
public IEnumerable <string> Resolve(ResolverContext resolverContext, WebAssetCollection assets) { var resolvedUrls = new List <string>(); foreach (var asset in assets) { resolvedUrls.AddRange(resolverFactory.Create(asset).Resolve(resolverContext)); } return(resolvedUrls .Distinct(StringComparer.OrdinalIgnoreCase) .Select((url) => urlResolver.Resolve(url))); }
public ScriptRegistrarTests() { httpContext = TestHelper.CreateMockedHttpContext(); scripts = new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath); scriptableComponents = new List <IScriptableComponent>(); resolver = new Mock <IWebAssetCollectionResolver>(); scriptWrapper = new Mock <ScriptWrapperBase>(); viewContext = new ViewContext { HttpContext = httpContext.Object, ViewData = new ViewDataDictionary() }; scriptRegistrar = new ScriptRegistrar(scripts, scriptableComponents, viewContext, resolver.Object, scriptWrapper.Object); }
public ScriptRegistrarTests() { httpContext = TestHelper.CreateMockedHttpContext(); scripts = new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath); scriptableComponents = new List<IScriptableComponent>(); resolver = new Mock<IWebAssetCollectionResolver>(); scriptWrapper = new Mock<ScriptWrapperBase>(); viewContext = new ViewContext { HttpContext = httpContext.Object, ViewData = new ViewDataDictionary() }; scriptRegistrar = new ScriptRegistrar(scripts, scriptableComponents, viewContext, resolver.Object, scriptWrapper.Object); }
/// <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(WebAssetCollection styleSheets, ViewContext viewContext, IWebAssetCollectionResolver resolver) { this.resolver = resolver; if (viewContext.HttpContext.Items[Key] != null) { throw new InvalidOperationException(Resources.TextResource.OnlyOneStyleSheetRegistrarIsAllowedInASingleRequest); } viewContext.HttpContext.Items[Key] = this; DefaultGroup = new WebAssetGroup("default", false) { DefaultPath = WebAssetDefaultSettings.StyleSheetFilesPath }; StyleSheets = styleSheets; styleSheets.Insert(0, DefaultGroup); ViewContext = viewContext; AssetHandlerPath = WebAssetHttpHandler.DefaultPath; }
public WebAssetCollectionBuilderTests() { _collection = new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath); _builder = new WebAssetCollectionBuilder(WebAssetType.JavaScript, _collection); }
public WebAssetCollectionTests() { _collection = new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath); }
public void WebAssetItemCollection_operator_should_return_internal_collection() { WebAssetCollection collection = _builder; Assert.Same(_collection, collection); }