forked from Dotnet-Boxed/Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SrcSubresourceIntegrityTagHelper.cs
47 lines (43 loc) · 1.93 KB
/
SrcSubresourceIntegrityTagHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace Boxed.AspNetCore.TagHelpers
{
using System.Text.Encodings.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Caching.Distributed;
/// <inheritdoc />
[HtmlTargetElement(Attributes = SrcAttributeName + "," + SubresourceIntegritySrcAttributeName)]
public class SrcSubresourceIntegrityTagHelper : SubresourceIntegrityTagHelper
{
private const string SrcAttributeName = "src";
private const string SubresourceIntegritySrcAttributeName = "asp-subresource-integrity-src";
/// <summary>
/// Initializes a new instance of the <see cref="SrcSubresourceIntegrityTagHelper"/> class.
/// </summary>
/// <param name="distributedCache">The distributed cache.</param>
/// <param name="hostingEnvironment">The hosting environment.</param>
/// <param name="actionContextAccessor">The MVC action context accessor.</param>
/// <param name="urlHelperFactory">The URL helper factory.</param>
/// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param>
public SrcSubresourceIntegrityTagHelper(
IDistributedCache distributedCache,
IHostingEnvironment hostingEnvironment,
IActionContextAccessor actionContextAccessor,
IUrlHelperFactory urlHelperFactory,
HtmlEncoder htmlEncoder)
: base(distributedCache, hostingEnvironment, actionContextAccessor, urlHelperFactory, htmlEncoder)
{
}
/// <inheritdoc />
[HtmlAttributeName(SubresourceIntegritySrcAttributeName)]
public override string Source
{
get;
set;
}
/// <inheritdoc />
protected override string UrlAttributeName => SrcAttributeName;
}
}