-
Notifications
You must be signed in to change notification settings - Fork 9.8k
/
TagHelperInitializerOfT.cs
38 lines (30 loc) · 1.11 KB
/
TagHelperInitializerOfT.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Razor.TagHelpers;
namespace Microsoft.AspNetCore.Mvc.Razor;
/// <inheritdoc />
public class TagHelperInitializer<TTagHelper> : ITagHelperInitializer<TTagHelper>
where TTagHelper : ITagHelper
{
private readonly Action<TTagHelper, ViewContext> _initializeDelegate;
/// <summary>
/// Creates a <see cref="TagHelperInitializer{TTagHelper}"/>.
/// </summary>
/// <param name="action">The initialization delegate.</param>
public TagHelperInitializer(Action<TTagHelper, ViewContext> action)
{
ArgumentNullException.ThrowIfNull(action);
_initializeDelegate = action;
}
/// <inheritdoc />
public void Initialize(TTagHelper helper, ViewContext context)
{
if (helper == null)
{
throw new ArgumentNullException(nameof(helper));
}
ArgumentNullException.ThrowIfNull(context);
_initializeDelegate(helper, context);
}
}