// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; namespace Microsoft.AspNetCore.Mvc.Rendering { /// /// Extension methods for . /// public static class ViewComponentHelperExtensions { /// /// Invokes a view component with the specified . /// /// The . /// The name of the view component. /// A that on completion returns the rendered . /// public static Task InvokeAsync(this IViewComponentHelper helper, string name) { if (helper == null) { throw new ArgumentNullException(nameof(helper)); } return helper.InvokeAsync(name, arguments: null); } /// /// Invokes a view component of type . /// /// The . /// The view component . /// A that on completion returns the rendered . /// public static Task InvokeAsync(this IViewComponentHelper helper, Type componentType) { if (helper == null) { throw new ArgumentNullException(nameof(helper)); } return helper.InvokeAsync(componentType, arguments: null); } /// /// Invokes a view component of type . /// /// The . /// Arguments to be passed to the invoked view component method. /// The of the view component. /// A that on completion returns the rendered . /// public static Task InvokeAsync(this IViewComponentHelper helper, object arguments) { if (helper == null) { throw new ArgumentNullException(nameof(helper)); } return helper.InvokeAsync(typeof(TComponent), arguments); } /// /// Invokes a view component of type . /// /// The . /// The of the view component. /// A that on completion returns the rendered . /// public static Task InvokeAsync(this IViewComponentHelper helper) { if (helper == null) { throw new ArgumentNullException(nameof(helper)); } return helper.InvokeAsync(typeof(TComponent), arguments: null); } } }