Make longest `@Html.DisplayForModel()` overload an extension method

- consistent with @Html.EditorForModel()` overloads
This commit is contained in:
dougbu 2014-07-30 22:59:43 -07:00
parent 40eb05f7e4
commit 7ec4ab021e
3 changed files with 19 additions and 32 deletions

View File

@ -247,17 +247,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
additionalViewData); additionalViewData);
} }
/// <inheritdoc />
public HtmlString DisplayForModel(string templateName,
string htmlFieldName,
object additionalViewData)
{
return GenerateDisplay(ViewData.ModelMetadata,
htmlFieldName,
templateName,
additionalViewData);
}
/// <inheritdoc /> /// <inheritdoc />
public HtmlString DisplayName(string expression) public HtmlString DisplayName(string expression)
{ {

View File

@ -90,18 +90,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html)
{ {
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: null); return html.Display(expression: string.Empty, templateName: null, htmlFieldName: null,
additionalViewData: null);
} }
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData)
{ {
return html.DisplayForModel(templateName: null, htmlFieldName: null, return html.Display(expression: string.Empty, templateName: null, htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName)
{ {
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: null); return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: null,
additionalViewData: null);
} }
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
@ -109,7 +111,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
string templateName, string templateName,
object additionalViewData) object additionalViewData)
{ {
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData); return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: null,
additionalViewData: additionalViewData);
} }
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
@ -117,7 +120,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
string templateName, string templateName,
string htmlFieldName) string htmlFieldName)
{ {
return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null); return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName,
additionalViewData: null);
}
public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html,
string templateName,
string htmlFieldName,
object additionalViewData)
{
return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName,
additionalViewData: additionalViewData);
} }
} }
} }

View File

@ -145,22 +145,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
string htmlFieldName, string htmlFieldName,
object additionalViewData); object additionalViewData);
/// <summary>
/// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and
/// additional view data.
/// </summary>
/// <param name="templateName">The name of the template that is used to render the object.</param>
/// <param name="htmlFieldName">
/// A string that is used to disambiguate the names of HTML input elements that are rendered for properties
/// that have the same name.
/// </param>
/// <param name="additionalViewData">
/// An anonymous object or dictionary that can contain additional view data that will be merged into the
/// <see cref="ViewDataDictionary{TModel}"/> instance that is created for the template.
/// </param>
/// <returns>The HTML markup for each property in the model.</returns>
HtmlString DisplayForModel(string templateName, string htmlFieldName, object additionalViewData);
/// <summary> /// <summary>
/// Gets the display name. /// Gets the display name.
/// </summary> /// </summary>