@@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
16
16
public static class HtmlHelperComponentExtensions
17
17
{
18
18
/// <summary>
19
- /// Renders the <typeparamref name="TComponent"/> <see cref="IComponent"/> .
19
+ /// Renders the <typeparamref name="TComponent"/>.
20
20
/// </summary>
21
21
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/>.</param>
22
22
/// <param name="renderMode">The <see cref="RenderMode"/> for the component.</param>
@@ -25,7 +25,7 @@ public static Task<IHtmlContent> RenderComponentAsync<TComponent>(this IHtmlHelp
25
25
=> RenderComponentAsync < TComponent > ( htmlHelper , renderMode , parameters : null ) ;
26
26
27
27
/// <summary>
28
- /// Renders the <typeparamref name="TComponent"/> <see cref="IComponent"/> .
28
+ /// Renders the <typeparamref name="TComponent"/>.
29
29
/// </summary>
30
30
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/>.</param>
31
31
/// <param name="parameters">An <see cref="object"/> containing the parameters to pass
@@ -36,15 +36,35 @@ public static Task<IHtmlContent> RenderComponentAsync<TComponent>(
36
36
this IHtmlHelper htmlHelper ,
37
37
RenderMode renderMode ,
38
38
object parameters ) where TComponent : IComponent
39
+ => RenderComponentAsync ( htmlHelper , typeof ( TComponent ) , renderMode , parameters ) ;
40
+
41
+ /// <summary>
42
+ /// Renders the specified <paramref name="componentType"/>.
43
+ /// </summary>
44
+ /// <param name="htmlHelper">The <see cref="IHtmlHelper"/>.</param>
45
+ /// <param name="componentType">The component type.</param>
46
+ /// <param name="parameters">An <see cref="object"/> containing the parameters to pass
47
+ /// to the component.</param>
48
+ /// <param name="renderMode">The <see cref="RenderMode"/> for the component.</param>
49
+ public static Task < IHtmlContent > RenderComponentAsync (
50
+ this IHtmlHelper htmlHelper ,
51
+ Type componentType ,
52
+ RenderMode renderMode ,
53
+ object parameters )
39
54
{
40
55
if ( htmlHelper is null )
41
56
{
42
57
throw new ArgumentNullException ( nameof ( htmlHelper ) ) ;
43
58
}
44
59
60
+ if ( componentType is null )
61
+ {
62
+ throw new ArgumentNullException ( nameof ( componentType ) ) ;
63
+ }
64
+
45
65
var viewContext = htmlHelper . ViewContext ;
46
66
var componentRenderer = viewContext . HttpContext . RequestServices . GetRequiredService < IComponentRenderer > ( ) ;
47
- return componentRenderer . RenderComponentAsync ( viewContext , typeof ( TComponent ) , renderMode , parameters ) ;
67
+ return componentRenderer . RenderComponentAsync ( viewContext , componentType , renderMode , parameters ) ;
48
68
}
49
69
}
50
70
}
0 commit comments