Add missing `RenderPartial(...)` overload
- #7127 - also remove some redundant `null` checks
This commit is contained in:
parent
40d027fca3
commit
1fa1d7df3e
|
|
@ -115,20 +115,8 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
/// This method synchronously calls and blocks on
|
/// This method synchronously calls and blocks on
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(this IHtmlHelper htmlHelper, string partialViewName)
|
||||||
this IHtmlHelper htmlHelper,
|
|
||||||
string partialViewName)
|
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(htmlHelper));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partialViewName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,16 +140,6 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
string partialViewName,
|
string partialViewName,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(htmlHelper));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partialViewName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData);
|
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,21 +158,8 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
/// This method synchronously calls and blocks on
|
/// This method synchronously calls and blocks on
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(this IHtmlHelper htmlHelper, string partialViewName, object model)
|
||||||
this IHtmlHelper htmlHelper,
|
|
||||||
string partialViewName,
|
|
||||||
object model)
|
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(htmlHelper));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partialViewName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, model, viewData: null);
|
return Partial(htmlHelper, partialViewName, model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,22 +209,9 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static void RenderPartial(
|
public static void RenderPartial(this IHtmlHelper htmlHelper, string partialViewName)
|
||||||
this IHtmlHelper htmlHelper,
|
|
||||||
string partialViewName)
|
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
RenderPartial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(htmlHelper));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partialViewName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
|
||||||
result.GetAwaiter().GetResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -278,18 +230,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
string partialViewName,
|
string partialViewName,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
RenderPartial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData);
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(htmlHelper));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partialViewName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData);
|
|
||||||
result.GetAwaiter().GetResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -303,10 +244,28 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
public static void RenderPartial(this IHtmlHelper htmlHelper, string partialViewName, object model)
|
||||||
|
{
|
||||||
|
RenderPartial(htmlHelper, partialViewName, model, viewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders HTML markup for the specified partial view.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
|
/// <param name="partialViewName">
|
||||||
|
/// The name or path of the partial view used to create the HTML markup. Must not be <c>null</c>.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="model">A model to pass into the partial view.</param>
|
||||||
|
/// <param name="viewData">A <see cref="ViewDataDictionary"/> to pass into the partial view.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
|
/// </remarks>
|
||||||
public static void RenderPartial(
|
public static void RenderPartial(
|
||||||
this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string partialViewName,
|
string partialViewName,
|
||||||
object model)
|
object model,
|
||||||
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
if (htmlHelper == null)
|
if (htmlHelper == null)
|
||||||
{
|
{
|
||||||
|
|
@ -318,7 +277,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
throw new ArgumentNullException(nameof(partialViewName));
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = htmlHelper.RenderPartialAsync(partialViewName, model, viewData: null);
|
var result = htmlHelper.RenderPartialAsync(partialViewName, model, viewData);
|
||||||
result.GetAwaiter().GetResult();
|
result.GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
|
||||||
{ helper => helper.RenderPartial("test"), null, null },
|
{ helper => helper.RenderPartial("test"), null, null },
|
||||||
{ helper => helper.RenderPartial("test", model), model, null },
|
{ helper => helper.RenderPartial("test", model), model, null },
|
||||||
{ helper => helper.RenderPartial("test", viewData), null, viewData },
|
{ helper => helper.RenderPartial("test", viewData), null, viewData },
|
||||||
|
{ helper => helper.RenderPartial("test", model, viewData), model, viewData },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue