From 7ec4ab021ef34f14dad1954b599e474203d33af7 Mon Sep 17 00:00:00 2001 From: dougbu Date: Wed, 30 Jul 2014 22:59:43 -0700 Subject: [PATCH] Make longest `@Html.DisplayForModel()` overload an extension method - consistent with @Html.EditorForModel()` overloads --- .../Rendering/Html/HtmlHelper.cs | 11 --------- .../Rendering/HtmlHelperDisplayExtensions.cs | 24 +++++++++++++++---- .../Rendering/IHtmlHelper.cs | 16 ------------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs index 92eb6e23f0..19b13152bb 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs @@ -247,17 +247,6 @@ namespace Microsoft.AspNet.Mvc.Rendering additionalViewData); } - /// - public HtmlString DisplayForModel(string templateName, - string htmlFieldName, - object additionalViewData) - { - return GenerateDisplay(ViewData.ModelMetadata, - htmlFieldName, - templateName, - additionalViewData); - } - /// public HtmlString DisplayName(string expression) { diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs index 0f772718b6..281ab758cc 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs @@ -90,18 +90,20 @@ namespace Microsoft.AspNet.Mvc.Rendering 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) { - return html.DisplayForModel(templateName: null, htmlFieldName: null, + return html.Display(expression: string.Empty, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } 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( @@ -109,7 +111,8 @@ namespace Microsoft.AspNet.Mvc.Rendering string templateName, 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( @@ -117,7 +120,18 @@ namespace Microsoft.AspNet.Mvc.Rendering string templateName, 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); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs index 21c27dd0a3..cee689b0b4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs @@ -145,22 +145,6 @@ namespace Microsoft.AspNet.Mvc.Rendering string htmlFieldName, object additionalViewData); - /// - /// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and - /// additional view data. - /// - /// The name of the template that is used to render the object. - /// - /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties - /// that have the same name. - /// - /// - /// An anonymous object or dictionary that can contain additional view data that will be merged into the - /// instance that is created for the template. - /// - /// The HTML markup for each property in the model. - HtmlString DisplayForModel(string templateName, string htmlFieldName, object additionalViewData); - /// /// Gets the display name. ///