Addressed code review comments.
This commit is contained in:
parent
5026788145
commit
671c7dd59e
|
|
@ -1 +1,5 @@
|
|||
<p>This is the DisplayForModel output. Once default templates are implemented this should go away.</p>
|
||||
@using System.Linq
|
||||
|
||||
<p>This is the DisplayForModel output. Once default templates are implemented this should go away.</p>
|
||||
<p><strong>User Name: </strong>@ViewData.Model.Name</p>
|
||||
<p><strong>User Model Metadata Property Count: </strong>@ViewData.ModelMetadata.Properties.Count()</p>
|
||||
|
|
@ -163,33 +163,26 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
}
|
||||
|
||||
public HtmlString Display(string expression,
|
||||
string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData)
|
||||
string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData)
|
||||
{
|
||||
var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
|
||||
|
||||
return GenerateDisplay(metadata,
|
||||
htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),
|
||||
templateName,
|
||||
additionalViewData);
|
||||
htmlFieldName ?? ExpressionHelper.GetExpressionText(expression),
|
||||
templateName,
|
||||
additionalViewData);
|
||||
}
|
||||
|
||||
public virtual HtmlString DisplayForModel(string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData)
|
||||
public HtmlString DisplayForModel(string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData)
|
||||
{
|
||||
var templateBuilder = new TemplateBuilder(ViewContext,
|
||||
ViewData,
|
||||
ViewData.ModelMetadata,
|
||||
htmlFieldName,
|
||||
templateName,
|
||||
readOnly: true,
|
||||
additionalViewData: additionalViewData);
|
||||
|
||||
var templateResult = templateBuilder.Build();
|
||||
|
||||
return new HtmlString(templateResult);
|
||||
return GenerateDisplay(ViewData.ModelMetadata,
|
||||
htmlFieldName,
|
||||
templateName,
|
||||
additionalViewData);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -1,29 +1,35 @@
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.Rendering
|
||||
{
|
||||
public static class DisplayForModelExtensions
|
||||
public static class HtmlHelperDisplayForModelExtensions
|
||||
{
|
||||
public static HtmlString DisplayForModel<TModel>(this IHtmlHelper<TModel> html)
|
||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html)
|
||||
{
|
||||
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||
}
|
||||
|
||||
public static HtmlString DisplayForModel<TModel>(this IHtmlHelper<TModel> html, object additionalViewData)
|
||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||
object additionalViewData)
|
||||
{
|
||||
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: additionalViewData);
|
||||
}
|
||||
|
||||
public static HtmlString DisplayForModel<TModel>(this IHtmlHelper<TModel> html, string templateName)
|
||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||
string templateName)
|
||||
{
|
||||
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: null);
|
||||
}
|
||||
|
||||
public static HtmlString DisplayForModel<TModel>(this IHtmlHelper<TModel> html, string templateName, object additionalViewData)
|
||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||
string templateName,
|
||||
object additionalViewData)
|
||||
{
|
||||
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
||||
}
|
||||
|
||||
public static HtmlString DisplayForModel<TModel>(this IHtmlHelper<TModel> html, string templateName, string htmlFieldName)
|
||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||
string templateName,
|
||||
string htmlFieldName)
|
||||
{
|
||||
return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,16 +69,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
/// </param>
|
||||
/// <returns>The HTML markup for each property in the object that is represented by the expression.</returns>
|
||||
HtmlString DisplayFor<TValue>(Expression<Func<TModel, TValue>> expression,
|
||||
string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData);
|
||||
string templateName,
|
||||
string htmlFieldName,
|
||||
object additionalViewData);
|
||||
|
||||
/// <summary>
|
||||
/// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and additional view data.
|
||||
/// 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 that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> instance that is created for the template.</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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue