Enable invoking a `ViewComponent` without arguments inside of a controller.
- Also updated doc comments to properly reflect `ViewComponent` `arguments` parameter.
This commit is contained in:
parent
f888ced1f2
commit
acd88d08ba
|
|
@ -209,6 +209,32 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="ViewComponentResult"/> by specifying the name of a view component to render.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="componentName">
|
||||||
|
/// The view component name. Can be a view component
|
||||||
|
/// <see cref="ViewComponents.ViewComponentDescriptor.ShortName"/> or
|
||||||
|
/// <see cref="ViewComponents.ViewComponentDescriptor.FullName"/>.</param>
|
||||||
|
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
||||||
|
[NonAction]
|
||||||
|
public virtual ViewComponentResult ViewComponent(string componentName)
|
||||||
|
{
|
||||||
|
return ViewComponent(componentName, arguments: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="ViewComponentResult"/> by specifying the <see cref="Type"/> of a view component to
|
||||||
|
/// render.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="componentType">The view component <see cref="Type"/>.</param>
|
||||||
|
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
||||||
|
[NonAction]
|
||||||
|
public virtual ViewComponentResult ViewComponent(Type componentType)
|
||||||
|
{
|
||||||
|
return ViewComponent(componentType, arguments: null);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="ViewComponentResult"/> by specifying the name of a view component to render.
|
/// Creates a <see cref="ViewComponentResult"/> by specifying the name of a view component to render.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -217,9 +243,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// <see cref="ViewComponents.ViewComponentDescriptor.ShortName"/> or
|
/// <see cref="ViewComponents.ViewComponentDescriptor.ShortName"/> or
|
||||||
/// <see cref="ViewComponents.ViewComponentDescriptor.FullName"/>.</param>
|
/// <see cref="ViewComponents.ViewComponentDescriptor.FullName"/>.</param>
|
||||||
/// <param name="arguments">
|
/// <param name="arguments">
|
||||||
/// An anonymous <see cref="object"/> containing arguments to be passed to the invoked view component method.
|
/// An <see cref="object"/> with properties representing arguments to be passed to the invoked view component
|
||||||
/// Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing
|
/// method. Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance
|
||||||
/// the invocation arguments.
|
/// containing the invocation arguments.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
|
|
@ -240,9 +266,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="componentType">The view component <see cref="Type"/>.</param>
|
/// <param name="componentType">The view component <see cref="Type"/>.</param>
|
||||||
/// <param name="arguments">
|
/// <param name="arguments">
|
||||||
/// An anonymous <see cref="object"/> containing arguments to be passed to the invoked view component method.
|
/// An <see cref="object"/> with properties representing arguments to be passed to the invoked view component
|
||||||
/// Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing
|
/// method. Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance
|
||||||
/// the invocation arguments.
|
/// containing the invocation arguments.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
/// <returns>The created <see cref="ViewComponentResult"/> object for the response.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the view component.</param>
|
/// <param name="name">The name of the view component.</param>
|
||||||
/// <param name="arguments">
|
/// <param name="arguments">
|
||||||
/// An anonymous <see cref="object"/> containing arguments to be passed to the invoked view component method.
|
/// An <see cref="object"/> with properties representing arguments to be passed to the invoked view component
|
||||||
/// Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing
|
/// method. Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance
|
||||||
/// the invocation arguments.
|
/// containing the invocation arguments.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns the rendered <see cref="IHtmlContent" />.
|
/// <returns>A <see cref="Task"/> that on completion returns the rendered <see cref="IHtmlContent" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
@ -30,9 +30,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="componentType">The view component <see cref="Type"/>.</param>
|
/// <param name="componentType">The view component <see cref="Type"/>.</param>
|
||||||
/// <param name="arguments">
|
/// <param name="arguments">
|
||||||
/// An anonymous <see cref="object"/> containing arguments to be passed to the invoked view component method.
|
/// An <see cref="object"/> with properties representing arguments to be passed to the invoked view component
|
||||||
/// Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing
|
/// method. Alternatively, an <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance
|
||||||
/// the invocation arguments.
|
/// containing the invocation arguments.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns the rendered <see cref="IHtmlContent" />.
|
/// <returns>A <see cref="Task"/> that on completion returns the rendered <see cref="IHtmlContent" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
var controller = new TestabilityController();
|
var controller = new TestabilityController();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = controller.ViewComponent("TagCloud", arguments: null);
|
var result = controller.ViewComponent("TagCloud");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
|
|
@ -575,7 +575,7 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
var controller = new TestabilityController();
|
var controller = new TestabilityController();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = controller.ViewComponent(typeof(TagCloudViewComponent), arguments: null);
|
var result = controller.ViewComponent(typeof(TagCloudViewComponent));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue