public AssetBundleTagHelper(IUrlHelperFactory urlHelperFactory, IHostEnvironmentType hostingEnvironment, AssetBundleOptions options, IFileVersionProvider fileVersionProvider) { this.hostingEnvironment = hostingEnvironment; this.urlHelperFactory = urlHelperFactory; this.options = options; this.fileVersionProvider = fileVersionProvider; }
private void EnsureFileVersionProvider() { if (FileVersionProvider == null) { FileVersionProvider = ViewContext.HttpContext.RequestServices.GetRequiredService <IFileVersionProvider>(); } }
public AppendVersionFilter( IFileVersionProvider fileVersionProvider, IHttpContextAccessor httpContextAccessor) { _fileVersionProvider = fileVersionProvider; _httpContextAccessor = httpContextAccessor; }
public PictureTagHelper( IUrlHelperFactory urlHelperFactory, HtmlEncoder htmlEncoder, IFileVersionProvider fileVersionProvider ) : base(urlHelperFactory, htmlEncoder) { FileVersionProvider = fileVersionProvider; }
public static FileVersioningFormatter BuildFormatter(IFileVersionProvider fileVersionProvider = null) { if (fileVersionProvider == null) { fileVersionProvider = new Mock <IFileVersionProvider>().Object; } return(new FileVersioningFormatter(fileVersionProvider)); }
public SourceAppendVersionTagHelper( IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory ) : base(urlHelperFactory, htmlEncoder) { FileVersionProvider = fileVersionProvider; }
public ImageTagHelper( IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory) : base(urlHelperFactory, htmlEncoder) { FileVersionProvider = fileVersionProvider; }
public ResourceManager( IOptions <ResourceManagementOptions> options, IFileVersionProvider fileVersionProvider) { _options = options.Value; _fileVersionProvider = fileVersionProvider; _builtResources = new Dictionary <string, ResourceRequiredContext[]>(StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Generates a has of the file. /// </summary> protected string AddFileVersionToPath(string fileName, IAsset asset) { if (_fileProvider == null) { _fileProvider = ViewContext.HttpContext.RequestServices.GetRequiredService <IFileVersionProvider>(); } return(_fileProvider.AddFileVersionToPath(ViewContext.HttpContext.Request.PathBase, fileName)); }
public ProductionScriptSrcTagHelper( IHostingEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, JavaScriptEncoder javaScriptEncoder, IUrlHelperFactory urlHelperFactory ) : base(hostingEnvironment, cacheProvider, fileVersionProvider, htmlEncoder, javaScriptEncoder, urlHelperFactory) { }
public ImageTagHelper( IMediaFileStore mediaFileStore, IHttpContextAccessor httpContextAccessor, IFileVersionProvider fileVersionProvider ) { _mediaFileStore = mediaFileStore; _httpContextAccessor = httpContextAccessor; _fileVersionProvider = fileVersionProvider; }
public AbpZeroTemplateLinkHrefTagHelper( IHostingEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, JavaScriptEncoder javaScriptEncoder, IUrlHelperFactory urlHelperFactory ) : base(hostingEnvironment, cacheProvider, fileVersionProvider, htmlEncoder, javaScriptEncoder, urlHelperFactory) { }
public string GenerateCacheKey(HttpContext context) { var cacheKey = new StringBuilder(Route); if (context.Request.Headers.TryGetValue("Accept-Encoding", out StringValues enc)) { cacheKey.Append(enc.ToString()); } IEnumerable <string> physicalFiles; var env = (IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment)); if (_fileVersionProvider == null) { var cache = (IMemoryCache)context.RequestServices.GetService(typeof(IMemoryCache)); _fileVersionProvider = context.RequestServices.GetRequiredService <IFileVersionProvider>(); } if (!Items.ContainsKey(PhysicalFilesKey)) { physicalFiles = ExpandGlobs(this, env); } else { physicalFiles = Items[PhysicalFilesKey] as IEnumerable <string>; } if (physicalFiles != null) { foreach (string file in physicalFiles) { cacheKey.Append(_fileVersionProvider.AddFileVersionToPath(context.Request.PathBase, file)); } } foreach (IProcessor processors in Processors) { try { cacheKey.Append(processors.CacheKey(context) ?? string.Empty); } catch (Exception ex) { throw new Exception($"CacheKey generation exception in {processors.GetType().FullName} processor", ex); } } using (var algo = SHA1.Create()) { byte[] buffer = Encoding.UTF8.GetBytes(cacheKey.ToString()); byte[] hash = algo.ComputeHash(buffer); return(WebEncoders.Base64UrlEncode(hash)); } }
/// <summary> /// Creates a new <see cref="ImageTagHelper"/>. /// </summary> /// <param name="hostingEnvironment">The <see cref="IHostingEnvironment"/>.</param> /// <param name="cacheProvider">The <see cref="TagHelperMemoryCacheProvider"/>.</param> /// <param name="fileVersionProvider">The <see cref="IFileVersionProvider"/>.</param> /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/> to use.</param> /// <param name="urlHelperFactory">The <see cref="IUrlHelperFactory"/>.</param> // Decorated with ActivatorUtilitiesConstructor since we want to influence tag helper activation // to use this constructor in the default case. public ImageTagHelper( IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory) : base(urlHelperFactory, htmlEncoder) { HostingEnvironment = hostingEnvironment; Cache = cacheProvider.Cache; FileVersionProvider = fileVersionProvider; }
public ImageUrlBuilder( IOptions <ImageWizardClientSettings> settings, IWebHostEnvironment env, IHttpContextAccessor httpContextAccessor, IFileVersionProvider fileVersionProvider) { Settings = settings; HostingEnvironment = env; HttpContextAccessor = httpContextAccessor; FileVersionProvider = fileVersionProvider; Filters = new List <string>(); }
/// <summary> /// Creates a new <see cref="LinkTagHelper"/>. /// </summary> /// <param name="hostingEnvironment">The <see cref="IHostingEnvironment"/>.</param> /// <param name="cacheProvider"></param> /// <param name="fileVersionProvider">The <see cref="IFileVersionProvider"/>.</param> /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param> /// <param name="javaScriptEncoder">The <see cref="JavaScriptEncoder"/>.</param> /// <param name="urlHelperFactory">The <see cref="IUrlHelperFactory"/>.</param> // Decorated with ActivatorUtilitiesConstructor since we want to influence tag helper activation // to use this constructor in the default case. public LinkTagHelper( IHostingEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, JavaScriptEncoder javaScriptEncoder, IUrlHelperFactory urlHelperFactory) : base(urlHelperFactory, htmlEncoder) { HostingEnvironment = hostingEnvironment; JavaScriptEncoder = javaScriptEncoder; Cache = cacheProvider.Cache; FileVersionProvider = fileVersionProvider; }
public SinkService( BundleSinkSettings settings, EntriesManifest webpackManifest, EntriesViewData viewData, IFileVersionProvider fileVersionProvider, IHttpContextAccessor httpContextAccessor ) { _settings = settings; _webpackManifest = webpackManifest; _viewData = viewData; _fileVersionProvider = fileVersionProvider; _httpContextAccessor = httpContextAccessor; }
public ResourceManager( IEnumerable <IResourceManifestProvider> resourceProviders, IResourceManifestState resourceManifestState, IOptions <ResourceManagementOptions> options, IFileVersionProvider fileVersionProvider) { _resourceManifestState = resourceManifestState; _options = options.Value; _providers = resourceProviders; _fileVersionProvider = fileVersionProvider; _builtResources = new Dictionary <string, ResourceRequiredContext[]>(StringComparer.OrdinalIgnoreCase); _localScripts = new HashSet <string>(); }
/// <summary> /// Creates a new <see cref="LinkTagHelper"/>. /// </summary> /// <param name="hostingEnvironment">The <see cref="IWebHostEnvironment"/>.</param> /// <param name="cache">The <see cref="IMemoryCache"/>.</param> /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param> /// <param name="javaScriptEncoder">The <see cref="JavaScriptEncoder"/>.</param> /// <param name="urlHelperFactory">The <see cref="IUrlHelperFactory"/>.</param> public LinkTagHelper( IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cache, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, JavaScriptEncoder javaScriptEncoder, IUrlHelperFactory urlHelperFactory, IServiceProvider serviceProvider) : base(hostingEnvironment, cache, fileVersionProvider, htmlEncoder, javaScriptEncoder, urlHelperFactory) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } _serviceProvider = serviceProvider; }
public Serializer( BundleSinkSettings settings, EntriesManifest webpackManifest, EntriesViewData viewData, IFileVersionProvider fileVersionProvider, string pathBase, string sinkName ) { _settings = settings; _webpackManifest = webpackManifest; _viewData = viewData; _fileVersionProvider = fileVersionProvider; _pathBase = pathBase; _sinkName = sinkName; }
public ResourceManager( IHttpContextAccessor httpContextAccessor, IEnumerable <IResourceManifestProvider> resourceProviders, IResourceManifestState resourceManifestState, IOptions <ResourceManagementOptions> options, IFileVersionProvider fileVersionProvider) { _resourceManifestState = resourceManifestState; _options = options; _pathBase = httpContextAccessor.HttpContext.Request.PathBase; _providers = resourceProviders; _fileVersionProvider = fileVersionProvider; _builtResources = new Dictionary <string, IList <ResourceRequiredContext> >(StringComparer.OrdinalIgnoreCase); _localScripts = new HashSet <string>(); }
public BundleTagHelper(IHostingEnvironment hostingEnvironment, IMemoryCache cache, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory, BundleOptions options = null, IBundleProvider bundleProvider = null, IFileVersionProvider fileVersionProvider = null) { if (hostingEnvironment == null) { throw new ArgumentNullException(nameof(hostingEnvironment)); } if (cache == null) { throw new ArgumentNullException(nameof(cache)); } if (htmlEncoder == null) { throw new ArgumentNullException(nameof(htmlEncoder)); } if (urlHelperFactory == null) { throw new ArgumentNullException(nameof(urlHelperFactory)); } if (fileVersionProvider == null) { throw new ArgumentNullException(nameof(fileVersionProvider)); } if (options == null) { options = new BundleOptions(); options.Configure(hostingEnvironment); } if (bundleProvider == null) { bundleProvider = new BundleProvider(); } _bundleProvider = bundleProvider; _options = options; _hostingEnvironment = hostingEnvironment; _cache = cache; _htmlEncoder = htmlEncoder; _urlHelperFactory = urlHelperFactory; _fileVersionProvider = fileVersionProvider; }
public TagBuilder GetTagBuilder(RequireSettings settings, string applicationPath, IFileVersionProvider fileVersionProvider) { string url; // Url priority: if (settings.DebugMode) { url = settings.CdnMode ? Coalesce(UrlCdnDebug, UrlDebug, UrlCdn, Url) : Coalesce(UrlDebug, Url, UrlCdnDebug, UrlCdn); } else { url = settings.CdnMode ? Coalesce(UrlCdn, Url, UrlCdnDebug, UrlDebug) : Coalesce(Url, UrlDebug, UrlCdn, UrlCdnDebug); } if (String.IsNullOrEmpty(url)) { url = null; } if (!String.IsNullOrEmpty(settings.Culture)) { string nearestCulture = FindNearestCulture(settings.Culture); if (!String.IsNullOrEmpty(nearestCulture)) { url = Path.ChangeExtension(url, nearestCulture + Path.GetExtension(url)); } } if (url.StartsWith("~/", StringComparison.Ordinal)) { if (!String.IsNullOrEmpty(_basePath)) { url = _basePath + url.Substring(1); } else { url = applicationPath + url.Substring(1); } } // If settings has value, it can override resource definition, otherwise use resource definition if (url != null && ((settings.AppendVersion.HasValue && settings.AppendVersion == true) || (!settings.AppendVersion.HasValue && AppendVersion == true))) { url = fileVersionProvider.AddFileVersionToPath(applicationPath, url); } // Don't prefix cdn if the path is absolute, or is in debug mode. if (!settings.DebugMode && !String.IsNullOrEmpty(settings.CdnBaseUrl) && !Uri.TryCreate(url, UriKind.Absolute, out var uri)) { url = settings.CdnBaseUrl + url; } var tagBuilder = new TagBuilder(TagName) { TagRenderMode = TagRenderMode }; if (!String.IsNullOrEmpty(CdnIntegrity) && url != null && url == UrlCdn) { tagBuilder.Attributes["integrity"] = CdnIntegrity; tagBuilder.Attributes["crossorigin"] = "anonymous"; } else if (!String.IsNullOrEmpty(CdnDebugIntegrity) && url != null && url == UrlCdnDebug) { tagBuilder.Attributes["integrity"] = CdnDebugIntegrity; tagBuilder.Attributes["crossorigin"] = "anonymous"; } if (_resourceAttributes.ContainsKey(Type)) { tagBuilder.MergeAttributes(_resourceAttributes[Type]); } if (Attributes != null) { tagBuilder.MergeAttributes(Attributes); } if (settings.HasAttributes) { tagBuilder.MergeAttributes(settings.Attributes); } if (!String.IsNullOrEmpty(FilePathAttributeName)) { if (!String.IsNullOrEmpty(url)) { tagBuilder.MergeAttribute(FilePathAttributeName, url, true); } } return(tagBuilder); }
public SVGUse(IUrlHelperFactory urlHelperFactory, HtmlEncoder htmlEncoder, IFileVersionProvider fileVersionProvider) : base(urlHelperFactory, htmlEncoder) { _fileVersionProvider = fileVersionProvider; }
public TagBuilder GetTagBuilder(RequireSettings settings, string applicationPath, IFileVersionProvider fileVersionProvider) { string url, filePathAttributeName = null; // Url priority: if (settings.DebugMode) { url = settings.CdnMode ? Coalesce(UrlCdnDebug, UrlDebug, UrlCdn, Url) : Coalesce(UrlDebug, Url, UrlCdnDebug, UrlCdn); } else { url = settings.CdnMode ? Coalesce(UrlCdn, Url, UrlCdnDebug, UrlDebug) : Coalesce(Url, UrlDebug, UrlCdn, UrlCdnDebug); } if (String.IsNullOrEmpty(url)) { url = null; } if (!String.IsNullOrEmpty(settings.Culture)) { string nearestCulture = FindNearestCulture(settings.Culture); if (!String.IsNullOrEmpty(nearestCulture)) { url = Path.ChangeExtension(url, nearestCulture + Path.GetExtension(url)); } } if (url != null && url.StartsWith("~/", StringComparison.Ordinal)) { if (!String.IsNullOrEmpty(_basePath)) { url = _basePath + url.Substring(1); } else { url = applicationPath + url.Substring(1); } } // If settings has value, it can override resource definition, otherwise use resource definition if (url != null && ((settings.AppendVersion.HasValue && settings.AppendVersion == true) || (!settings.AppendVersion.HasValue && AppendVersion == true))) { url = fileVersionProvider.AddFileVersionToPath(applicationPath, url); } // Don't prefix cdn if the path is absolute, or is in debug mode. if (!settings.DebugMode && !String.IsNullOrEmpty(settings.CdnBaseUrl) && !Uri.TryCreate(url, UriKind.Absolute, out var uri)) { url = settings.CdnBaseUrl + url; } TagBuilder tagBuilder; switch (Type) { case "script": tagBuilder = new TagBuilder("script"); filePathAttributeName = "src"; break; case "stylesheet": if (url == null && InnerContent != null) { // Inline style declaration tagBuilder = new TagBuilder("style") { Attributes = { { "type", "text/css" } } }; } else { // Stylesheet resource tagBuilder = new TagBuilder("link") { TagRenderMode = TagRenderMode.SelfClosing, Attributes = { { "type", "text/css" }, { "rel", "stylesheet" } } }; filePathAttributeName = "href"; } break; case "link": tagBuilder = new TagBuilder("link") { TagRenderMode = TagRenderMode.SelfClosing }; filePathAttributeName = "href"; break; default: tagBuilder = new TagBuilder("meta") { TagRenderMode = TagRenderMode.SelfClosing }; break; } if (!String.IsNullOrEmpty(CdnIntegrity) && url != null && url == UrlCdn) { tagBuilder.Attributes["integrity"] = CdnIntegrity; tagBuilder.Attributes["crossorigin"] = "anonymous"; } else if (!String.IsNullOrEmpty(CdnDebugIntegrity) && url != null && url == UrlCdnDebug) { tagBuilder.Attributes["integrity"] = CdnDebugIntegrity; tagBuilder.Attributes["crossorigin"] = "anonymous"; } if (Attributes != null) { tagBuilder.MergeAttributes(Attributes); } if (settings.HasAttributes) { tagBuilder.MergeAttributes(settings.Attributes); } if (!String.IsNullOrEmpty(url) && filePathAttributeName != null) { tagBuilder.MergeAttribute(filePathAttributeName, url, true); } else if (!String.IsNullOrEmpty(InnerContent)) { tagBuilder.InnerHtml.AppendHtml(InnerContent); } return(tagBuilder); }
public LazyImageTagHelper(IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, IUrlHelperFactory urlHelperFactory) : base(fileVersionProvider, htmlEncoder, urlHelperFactory) { }
public LinkPolyfillTagHelper(IFileVersionProvider fileVersionProvider) { this._fileVersionProvider = fileVersionProvider; }
public InlineStyleTagHelper(IWebHostEnvironment hostingEnvironment, TagHelperMemoryCacheProvider cacheProvider, IFileVersionProvider fileVersionProvider, HtmlEncoder htmlEncoder, JavaScriptEncoder javaScriptEncoder, IUrlHelperFactory urlHelperFactory) : base(hostingEnvironment, cacheProvider, fileVersionProvider, htmlEncoder, javaScriptEncoder, urlHelperFactory) { }
public FileVersioningFormatter(IFileVersionProvider fileVersionProvider) { _fileVersionProvider = fileVersionProvider; }
public AboutWindow(IFileVersionProvider fileVersionProvider) : base("About") =>