From 66ca046135aff85c1e899cd139d099191e444c7b Mon Sep 17 00:00:00 2001 From: dougbu Date: Fri, 25 Apr 2014 22:49:00 -0700 Subject: [PATCH] Reintroduce `IHtmlHelper` and use it everywhere possible - no more `IHtmlHelper` in `DefaultDisplayTemplates` and also no need for `ViewDataDictionary` in a few places - mostly removals from `IHtmlHelper` but did cleanup comments and add `[NotNull]` for `DisplayFor()`, `DisplayNameFor()`, `DisplayNameForInnerType()`, and `LabelFor()` - also add `[NotNull]` for `this` and `Expression` parameters in some extension methods --- src/Microsoft.AspNet.Mvc.Core/Controller.cs | 2 +- .../DefaultControllerFactory.cs | 2 +- .../Microsoft.AspNet.Mvc.Core.kproj | 1 + .../Rendering/Html/DefaultDisplayTemplates.cs | 20 +- .../Rendering/Html/HtmlHelper.cs | 40 +- .../Rendering/Html/HtmlHelperOfT.cs | 5 +- .../Rendering/Html/TemplateBuilder.cs | 2 +- .../Rendering/Html/TemplateRenderer.cs | 25 +- .../Rendering/HtmlHelperDisplayExtensions.cs | 57 +-- .../HtmlHelperDisplayNameExtensions.cs | 12 +- .../Rendering/HtmlHelperFormExtensions.cs | 48 ++- .../Rendering/HtmlHelperInputExtensions.cs | 75 ++-- .../Rendering/HtmlHelperLabelExtensions.cs | 20 +- .../Rendering/HtmlHelperLinkExtensions.cs | 48 +-- .../Rendering/HtmlHelperNameExtensions.cs | 2 +- .../Rendering/HtmlHelperPartialExtensions.cs | 36 +- .../Rendering/HtmlHelperSelectExtensions.cs | 23 +- .../HtmlHelperValidationExtensions.cs | 33 +- .../Rendering/HtmlHelperValueExtensions.cs | 12 +- .../Rendering/IHtmlHelper.cs | 358 +++++++++++++++++ .../Rendering/IHtmlHelperOfT.cs | 365 +----------------- src/Microsoft.AspNet.Mvc/MvcServices.cs | 2 +- 22 files changed, 658 insertions(+), 530 deletions(-) create mode 100644 src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/Controller.cs b/src/Microsoft.AspNet.Mvc.Core/Controller.cs index 750188c621..36a3a06a9a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Controller.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Mvc public IUrlHelper Url { get; set; } - public ViewDataDictionary ViewData { get; set; } + public ViewDataDictionary ViewData { get; set; } public dynamic ViewBag { diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs index 821c7030f8..e2a696a040 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs @@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc { Injector.InjectProperty(controller, "ActionContext", actionContext); - var viewData = new ViewDataDictionary( + var viewData = new ViewDataDictionary( _serviceProvider.GetService(), actionContext.ModelState); Injector.InjectProperty(controller, "ViewData", viewData); diff --git a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj index b2197b43ab..319d5a4edd 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj +++ b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj @@ -182,6 +182,7 @@ + diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs index 4d86784918..1a960797e5 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class DefaultDisplayTemplates { - public static string BooleanTemplate(IHtmlHelper html) + public static string BooleanTemplate(IHtmlHelper html) { bool? value = null; if (html.ViewData.Model != null) @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.Rendering return inputTag.ToString(TagRenderMode.SelfClosing); } - private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) + private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) { var selectTag = new TagBuilder("select"); selectTag.AddCssClass("list-box"); @@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.Rendering }; } - public static string CollectionTemplate(IHtmlHelper html) + public static string CollectionTemplate(IHtmlHelper html) { var model = html.ViewData.ModelMetadata.Model; if (model == null) @@ -158,7 +158,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - public static string DecimalTemplate(IHtmlHelper html) + public static string DecimalTemplate(IHtmlHelper html) { if (html.ViewData.TemplateInfo.FormattedModelValue == html.ViewData.ModelMetadata.Model) { @@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.Rendering return StringTemplate(html); } - public static string EmailAddressTemplate(IHtmlHelper html) + public static string EmailAddressTemplate(IHtmlHelper html) { var uriString = "mailto:" + ((html.ViewData.Model == null) ? string.Empty : html.ViewData.Model.ToString()); var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? @@ -179,18 +179,18 @@ namespace Microsoft.AspNet.Mvc.Rendering return HyperlinkTemplate(uriString, linkedText); } - public static string HiddenInputTemplate(IHtmlHelper html) + public static string HiddenInputTemplate(IHtmlHelper html) { // TODO: add ModelMetadata.HideSurroundingHtml and use here (return string.Empty) return StringTemplate(html); } - public static string HtmlTemplate(IHtmlHelper html) + public static string HtmlTemplate(IHtmlHelper html) { return html.ViewData.TemplateInfo.FormattedModelValue.ToString(); } - public static string ObjectTemplate(IHtmlHelper html) + public static string ObjectTemplate(IHtmlHelper html) { var viewData = html.ViewData; var templateInfo = viewData.TemplateInfo; @@ -261,12 +261,12 @@ namespace Microsoft.AspNet.Mvc.Rendering !templateInfo.Visited(metadata); } - public static string StringTemplate(IHtmlHelper html) + public static string StringTemplate(IHtmlHelper html) { return html.Encode(html.ViewData.TemplateInfo.FormattedModelValue); } - public static string UrlTemplate(IHtmlHelper html) + public static string UrlTemplate(IHtmlHelper html) { var uriString = (html.ViewData.Model == null) ? string.Empty : html.ViewData.Model.ToString(); var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs index c6a45f17ac..e65afb1a59 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Default implementation of non-generic portions of . /// - public class HtmlHelper : ICanHasViewContext + public class HtmlHelper : IHtmlHelper, ICanHasViewContext { public static readonly string ValidationInputCssClassName = "input-validation-error"; public static readonly string ValidationInputValidCssClassName = "input-validation-valid"; @@ -52,8 +52,10 @@ namespace Microsoft.AspNet.Mvc.Rendering IdAttributeDotReplacement = "_"; } + /// public string IdAttributeDotReplacement { get; set; } + /// public ViewContext ViewContext { get @@ -71,6 +73,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } + /// public dynamic ViewBag { get @@ -79,6 +82,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } + /// public ViewDataDictionary ViewData { get @@ -89,6 +93,7 @@ namespace Microsoft.AspNet.Mvc.Rendering protected IModelMetadataProvider MetadataProvider { get; private set; } + /// public HtmlString ActionLink( [NotNull] string linkText, string actionName, @@ -161,11 +166,13 @@ namespace Microsoft.AspNet.Mvc.Rendering ViewContext = viewContext; } + /// public HtmlString AntiForgeryToken() { return _antiForgeryInstance.GetHtml(ViewContext.HttpContext); } + /// public MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes) { @@ -179,37 +186,44 @@ namespace Microsoft.AspNet.Mvc.Rendering return GenerateForm(actionName, controllerName, routeValues, method, htmlAttributeDictionary); } + /// public void EndForm() { var mvcForm = CreateForm(); mvcForm.EndForm(); } + /// public HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes) { return GenerateCheckBox(metadata: null, name: name, isChecked: isChecked, htmlAttributes: htmlAttributes); } + /// public string Encode(string value) { return (!string.IsNullOrEmpty(value)) ? WebUtility.HtmlEncode(value) : string.Empty; } + /// public string Encode(object value) { return value != null ? WebUtility.HtmlEncode(value.ToString()) : string.Empty; } + /// public string FormatValue(object value, string format) { return ViewDataDictionary.FormatValue(value, format); } + /// public string GenerateIdFromName([NotNull] string name) { return TagBuilder.CreateSanitizedId(name, IdAttributeDotReplacement); } + /// public HtmlString Display(string expression, string templateName, string htmlFieldName, @@ -223,6 +237,7 @@ namespace Microsoft.AspNet.Mvc.Rendering additionalViewData); } + /// public HtmlString DisplayForModel(string templateName, string htmlFieldName, object additionalViewData) @@ -232,7 +247,8 @@ namespace Microsoft.AspNet.Mvc.Rendering templateName, additionalViewData); } - + + /// public HtmlString DisplayName(string expression) { var modelMetadata = string.IsNullOrEmpty(expression) ? @@ -245,6 +261,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } + /// public HtmlString DropDownList(string name, IEnumerable selectList, string optionLabel, object htmlAttributes) { @@ -256,13 +273,14 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: htmlAttributes); } + /// public HtmlString Hidden(string name, object value, object htmlAttributes) { return GenerateHidden(metadata: null, name: name, value: value, useViewData: (value == null), htmlAttributes: htmlAttributes); } - + /// public HtmlString Label(string expression, string labelText, object htmlAttributes) { var modelMetadata = string.IsNullOrEmpty(expression)? @@ -278,12 +296,14 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes); } + /// public virtual HtmlString Name(string name) { var fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name); return new HtmlString(Encode(fullName)); } + /// public async Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData) { @@ -295,6 +315,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } + /// public Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData) { return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer); @@ -351,27 +372,32 @@ namespace Microsoft.AspNet.Mvc.Rendering } } + /// public HtmlString Password(string name, object value, object htmlAttributes) { return GeneratePassword(metadata: null, name: name, value: value, htmlAttributes: htmlAttributes); } + /// public HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes) { return GenerateRadioButton(metadata: null, name: name, value: value, isChecked: isChecked, htmlAttributes: htmlAttributes); } + /// public HtmlString Raw(string value) { return new HtmlString(value); } + /// public HtmlString Raw(object value) { return new HtmlString(value == null ? null : value.ToString()); } + /// public virtual HtmlString ValidationSummary(bool excludePropertyErrors, string message, IDictionary htmlAttributes) { var formContext = ViewContext.ClientValidationEnabled ? ViewContext.FormContext : null; @@ -481,12 +507,14 @@ namespace Microsoft.AspNet.Mvc.Rendering } } + /// public HtmlString TextBox(string name, object value, string format, IDictionary htmlAttributes) { return GenerateTextBox(metadata: null, name: name, value: value, format: format, htmlAttributes: htmlAttributes); } + /// public HtmlString Value([NotNull] string name, string format) { return GenerateValue(name, value: null, format: format, useViewData: true); @@ -589,7 +617,7 @@ namespace Microsoft.AspNet.Mvc.Rendering format: null, htmlAttributes: htmlAttributeDictionary); } - + protected virtual HtmlString GenerateDisplayName([NotNull] ModelMetadata metadata, string htmlFieldName) { // We don't call ModelMetadata.GetDisplayName here because @@ -603,7 +631,7 @@ namespace Microsoft.AspNet.Mvc.Rendering string.Empty : htmlFieldName.Split('.').Last(); } - + return new HtmlString(Encode(resolvedDisplayName)); } @@ -695,7 +723,7 @@ namespace Microsoft.AspNet.Mvc.Rendering format: null, htmlAttributes: htmlAttributeDictionary); } - + protected virtual HtmlString GenerateLabel([NotNull] ModelMetadata metadata, string htmlFieldName, string labelText, diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs index 3cd05f7fa3..d8de58c5d2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs @@ -91,7 +91,8 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString DisplayNameForInnerType(Expression> expression) + public HtmlString DisplayNameForInnerType( + [NotNull] Expression> expression) { var metadata = ExpressionMetadataProvider. FromLambdaExpression( @@ -175,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString ValueFor(Expression> expression, string format) + public HtmlString ValueFor([NotNull] Expression> expression, string format) { var metadata = GetModelMetadata(expression); return GenerateValue(ExpressionHelper.GetExpressionText(expression), metadata.Model, format, diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateBuilder.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateBuilder.cs index d534a72ad9..1b7a192b3a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateBuilder.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Mvc.Rendering return string.Empty; } - var viewData = new ViewDataDictionary(_viewData) + var viewData = new ViewDataDictionary(_viewData) { Model = _metadata.Model, ModelMetadata = _metadata diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateRenderer.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateRenderer.cs index 1b966928ea..8e9093e11e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateRenderer.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/TemplateRenderer.cs @@ -14,8 +14,8 @@ namespace Microsoft.AspNet.Mvc.Rendering private static readonly string DisplayTemplateViewPath = "DisplayTemplates"; private static readonly string EditorTemplateViewPath = "EditorTemplates"; - private static readonly Dictionary, string>> _defaultDisplayActions = - new Dictionary, string>>(StringComparer.OrdinalIgnoreCase) + private static readonly Dictionary> _defaultDisplayActions = + new Dictionary>(StringComparer.OrdinalIgnoreCase) { { "EmailAddress", DefaultDisplayTemplates.EmailAddressTemplate }, { "HiddenInput", DefaultDisplayTemplates.HiddenInputTemplate }, @@ -30,16 +30,17 @@ namespace Microsoft.AspNet.Mvc.Rendering }; private ViewContext _viewContext; - private ViewDataDictionary _viewData; + private ViewDataDictionary _viewData; private IViewEngine _viewEngine; private string _templateName; private bool _readOnly; - public TemplateRenderer([NotNull] IViewEngine viewEngine, - [NotNull] ViewContext viewContext, - [NotNull] ViewDataDictionary viewData, - string templateName, - bool readOnly) + public TemplateRenderer( + [NotNull] IViewEngine viewEngine, + [NotNull] ViewContext viewContext, + [NotNull] ViewDataDictionary viewData, + string templateName, + bool readOnly) { _viewEngine = viewEngine; _viewContext = viewContext; @@ -75,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - Func, string> defaultAction; + Func defaultAction; if (defaultActions.TryGetValue(viewName, out defaultAction)) { return defaultAction(MakeHtmlHelper(_viewContext, _viewData)); @@ -86,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Rendering Resources.FormatTemplateHelpers_NoTemplate(_viewData.ModelMetadata.RealModelType.FullName)); } - private Dictionary, string>> GetDefaultActions() + private Dictionary> GetDefaultActions() { if (_readOnly) { @@ -170,9 +171,9 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - private static IHtmlHelper MakeHtmlHelper(ViewContext viewContext, ViewDataDictionary viewData) + private static IHtmlHelper MakeHtmlHelper(ViewContext viewContext, ViewDataDictionary viewData) { - var newHelper = viewContext.HttpContext.RequestServices.GetService>(); + var newHelper = viewContext.HttpContext.RequestServices.GetService(); var contextable = newHelper as ICanHasViewContext; if (contextable != null) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs index fd0390762a..a31b34fbdc 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs @@ -5,39 +5,42 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperDisplayExtensions { - public static HtmlString Display([NotNull] this IHtmlHelper html, - string expression) + public static HtmlString Display([NotNull] this IHtmlHelper html, string expression) { return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } - public static HtmlString Display([NotNull] this IHtmlHelper html, - string expression, - object additionalViewData) + public static HtmlString Display( + [NotNull] this IHtmlHelper html, + string expression, + object additionalViewData) { return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString Display([NotNull] this IHtmlHelper html, - string expression, - string templateName) + public static HtmlString Display( + [NotNull] this IHtmlHelper html, + string expression, + string templateName) { return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: null); } - public static HtmlString Display([NotNull] this IHtmlHelper html, - string expression, - string templateName, - object additionalViewData) + public static HtmlString Display( + [NotNull] this IHtmlHelper html, + string expression, + string templateName, + object additionalViewData) { return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString Display([NotNull] this IHtmlHelper html, - string expression, - string templateName, - string htmlFieldName) + public static HtmlString Display( + [NotNull] this IHtmlHelper html, + string expression, + string templateName, + string htmlFieldName) { return html.Display(expression, templateName, htmlFieldName, additionalViewData: null); } @@ -82,34 +85,34 @@ namespace Microsoft.AspNet.Mvc.Rendering additionalViewData: null); } - 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); } - 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, 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); } - public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, - string templateName, - object additionalViewData) + public static HtmlString DisplayForModel( + [NotNull] this IHtmlHelper html, + string templateName, + object additionalViewData) { return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, - string templateName, - string htmlFieldName) + public static HtmlString DisplayForModel( + [NotNull] this IHtmlHelper html, + string templateName, + string htmlFieldName) { return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs index e4ed3cf7d7..9e357af2b9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs @@ -1,7 +1,7 @@ - -using System; +using System; using System.Collections.Generic; using System.Linq.Expressions; + namespace Microsoft.AspNet.Mvc.Rendering { /// @@ -12,9 +12,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Gets the display name for the current model. /// - /// The instance that this method extends. /// An that represents HTML markup. - public static HtmlString DisplayNameForModel([NotNull] this IHtmlHelper htmlHelper) + public static HtmlString DisplayNameForModel([NotNull] this IHtmlHelper htmlHelper) { return htmlHelper.DisplayName(string.Empty); } @@ -27,8 +26,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// The display name for the model. /// - public static HtmlString DisplayNameFor(this IHtmlHelper> htmlHelper, - Expression> expression) + public static HtmlString DisplayNameFor( + [NotNull] this IHtmlHelper> htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.DisplayNameForInnerType(expression); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperFormExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperFormExtensions.cs index 74ce95ce5a..b4826190e0 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperFormExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperFormExtensions.cs @@ -3,62 +3,80 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperFormExtensions { - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper) + public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper) { // Generates
. return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null, method: FormMethod.Post, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, FormMethod method) + public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, FormMethod method) { return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null, method: method, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, FormMethod method, - object htmlAttributes) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + FormMethod method, + object htmlAttributes) { return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null, method: method, htmlAttributes: htmlAttributes); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, object routeValues) + public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, object routeValues) { return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: routeValues, method: FormMethod.Post, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, string actionName, - string controllerName) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + string actionName, + string controllerName) { return htmlHelper.BeginForm(actionName, controllerName, routeValues: null, method: FormMethod.Post, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, string actionName, - string controllerName, object routeValues) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + string actionName, + string controllerName, + object routeValues) { return htmlHelper.BeginForm(actionName, controllerName, routeValues, FormMethod.Post, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, string actionName, - string controllerName, FormMethod method) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + string actionName, + string controllerName, + FormMethod method) { return htmlHelper.BeginForm(actionName, controllerName, routeValues: null, method: method, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, string actionName, - string controllerName, object routeValues, FormMethod method) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + string actionName, + string controllerName, + object routeValues, + FormMethod method) { return htmlHelper.BeginForm(actionName, controllerName, routeValues, method, htmlAttributes: null); } - public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, string actionName, - string controllerName, FormMethod method, object htmlAttributes) + public static MvcForm BeginForm( + [NotNull] this IHtmlHelper htmlHelper, + string actionName, + string controllerName, + FormMethod method, + object htmlAttributes) { return htmlHelper.BeginForm(actionName, controllerName, routeValues: null, method: method, htmlAttributes: htmlAttributes); diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs index 82f52dedfd..1d50073b3e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs @@ -6,18 +6,22 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperInputExtensions { - public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string name) { return htmlHelper.CheckBox(name, isChecked: null, htmlAttributes: null); } - public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString CheckBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, bool isChecked) { return htmlHelper.CheckBox(name, isChecked, htmlAttributes: null); } - public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString CheckBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, object htmlAttributes) { return htmlHelper.CheckBox(name, isChecked: null, htmlAttributes: htmlAttributes); @@ -29,12 +33,14 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlHelper.CheckBoxFor(expression, htmlAttributes: null); } - public static HtmlString Hidden([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString Hidden([NotNull] this IHtmlHelper htmlHelper, string name) { return htmlHelper.Hidden(name, value: null, htmlAttributes: null); } - public static HtmlString Hidden([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString Hidden( + [NotNull] this IHtmlHelper htmlHelper, + string name, object value) { return htmlHelper.Hidden(name, value, htmlAttributes: null); @@ -46,12 +52,14 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlHelper.HiddenFor(expression, htmlAttributes: null); } - public static HtmlString Password([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString Password([NotNull] this IHtmlHelper htmlHelper, string name) { return htmlHelper.Password(name, value: null, htmlAttributes: null); } - public static HtmlString Password([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString Password( + [NotNull] this IHtmlHelper htmlHelper, + string name, object value) { return htmlHelper.Password(name, value, htmlAttributes: null); @@ -63,20 +71,28 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlHelper.PasswordFor(expression, htmlAttributes: null); } - public static HtmlString RadioButton([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString RadioButton( + [NotNull] this IHtmlHelper htmlHelper, + string name, object value) { return htmlHelper.RadioButton(name, value, isChecked: null, htmlAttributes: null); } - public static HtmlString RadioButton([NotNull] this IHtmlHelper htmlHelper, string name, - object value, object htmlAttributes) + public static HtmlString RadioButton( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + object htmlAttributes) { return htmlHelper.RadioButton(name, value, isChecked: null, htmlAttributes: htmlAttributes); } - public static HtmlString RadioButton([NotNull] this IHtmlHelper htmlHelper, string name, - object value, bool isChecked) + public static HtmlString RadioButton( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + bool isChecked) { return htmlHelper.RadioButton(name, value, isChecked, htmlAttributes: null); } @@ -87,38 +103,53 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name) { return TextBox(htmlHelper, name, value: null); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString TextBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, object value) { return TextBox(htmlHelper, name, value, format: null); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name, - object value, string format) + public static HtmlString TextBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + string format) { return TextBox(htmlHelper, name, value, format, htmlAttributes: null); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name, - object value, object htmlAttributes) + public static HtmlString TextBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + object htmlAttributes) { return TextBox(htmlHelper, name, value, format: null, htmlAttributes: htmlAttributes); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name, - object value, string format, object htmlAttributes) + public static HtmlString TextBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + string format, + object htmlAttributes) { return htmlHelper.TextBox(name, value, format, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); } - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name, - object value, IDictionary htmlAttributes) + public static HtmlString TextBox( + [NotNull] this IHtmlHelper htmlHelper, + string name, + object value, + IDictionary htmlAttributes) { return htmlHelper.TextBox(name, value, format: null, htmlAttributes: htmlAttributes); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs index ed16dab542..70035e4546 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs @@ -5,16 +5,14 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperLabelExtensions { - public static HtmlString Label([NotNull] this IHtmlHelper html, string expression) + public static HtmlString Label([NotNull] this IHtmlHelper html, string expression) { return html.Label(expression, labelText: null, htmlAttributes: null); } - public static HtmlString Label([NotNull] this IHtmlHelper html, - string expression, - string labelText) + public static HtmlString Label([NotNull] this IHtmlHelper html, string expression, string labelText) { return html.Label(expression, labelText, htmlAttributes: null); } @@ -39,25 +37,25 @@ namespace Microsoft.AspNet.Mvc.Rendering return html.LabelFor(expression, labelText: null, htmlAttributes: htmlAttributes); } - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper html) { return LabelForModel(html, labelText: null); } - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText) { return html.Label(expression: string.Empty, labelText: labelText, htmlAttributes: null); } - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, - object htmlAttributes) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, object htmlAttributes) { return html.Label(expression: string.Empty, labelText: null, htmlAttributes: htmlAttributes); } - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, - string labelText, - object htmlAttributes) + public static HtmlString LabelForModel( + [NotNull] this IHtmlHelper html, + string labelText, + object htmlAttributes) { return html.Label(expression: string.Empty, labelText: labelText, htmlAttributes: htmlAttributes); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs index ffcb276858..fc38d04928 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLinkExtensions.cs @@ -3,9 +3,9 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperLinkExtensions { - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, - [NotNull] string linkText, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, + [NotNull] string linkText, string actionName) { return helper.ActionLink( @@ -19,10 +19,10 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: null); } - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, - [NotNull] string linkText, - string actionName, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, + [NotNull] string linkText, + string actionName, object routeValues) { return helper.ActionLink( @@ -36,11 +36,11 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: null); } - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, - [NotNull] string linkText, - string actionName, - object routeValues, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, + [NotNull] string linkText, + string actionName, + object routeValues, object htmlAttributes) { return helper.ActionLink( @@ -54,10 +54,10 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: htmlAttributes); } - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, - [NotNull] string linkText, - string actionName, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, + [NotNull] string linkText, + string actionName, string controllerName) { return helper.ActionLink( @@ -71,8 +71,8 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: null); } - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, [NotNull] string linkText, string actionName, string controllerName, @@ -89,12 +89,12 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlAttributes: null); } - public static HtmlString ActionLink( - [NotNull] this IHtmlHelper helper, - [NotNull] string linkText, - string actionName, - string controllerName, - object routeValues, + public static HtmlString ActionLink( + [NotNull] this IHtmlHelper helper, + [NotNull] string linkText, + string actionName, + string controllerName, + object routeValues, object htmlAttributes) { return helper.ActionLink( diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs index adf52f50ca..1c58924329 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc.Rendering ///
/// The instance that this method extends. /// An that represents HTML markup. - public static HtmlString NameForModel([NotNull] this IHtmlHelper htmlHelper) + public static HtmlString NameForModel([NotNull] this IHtmlHelper htmlHelper) { return htmlHelper.Name(string.Empty); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperPartialExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperPartialExtensions.cs index a40721a040..9ebe0a4da1 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperPartialExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperPartialExtensions.cs @@ -7,13 +7,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with the parent's view data and model to a string. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// /// A that represents when rendering to the has completed. /// - public static Task PartialAsync([NotNull] this IHtmlHelper htmlHelper, + public static Task PartialAsync( + [NotNull] this IHtmlHelper htmlHelper, [NotNull] string partialViewName) { return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null); @@ -22,7 +22,6 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with the given view data and, implicitly, the given view data's model to a string. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// @@ -31,8 +30,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A that represents when rendering to the has completed. /// - public static Task PartialAsync([NotNull] this IHtmlHelper htmlHelper, - [NotNull] string partialViewName, ViewDataDictionary viewData) + public static Task PartialAsync( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] string partialViewName, + ViewDataDictionary viewData) { return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); } @@ -40,15 +41,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with an empty view data and the given model to a string. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// The model to provide to the partial view that will be rendered. /// /// A that represents when rendering to the has completed. /// - public static Task PartialAsync([NotNull] this IHtmlHelper htmlHelper, - [NotNull] string partialViewName, object model) + public static Task PartialAsync( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] string partialViewName, + object model) { return htmlHelper.PartialAsync(partialViewName, model, viewData: null); } @@ -56,11 +58,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with the parent's view data and model. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// A that represents when rendering has completed. - public static Task RenderPartialAsync([NotNull] this IHtmlHelper htmlHelper, + public static Task RenderPartialAsync( + [NotNull] this IHtmlHelper htmlHelper, [NotNull] string partialViewName) { return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, @@ -70,15 +72,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with the given view data and, implicitly, the given view data's model. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// /// The that is provided to the partial view that will be rendered. /// /// A that represents when rendering has completed. - public static Task RenderPartialAsync([NotNull] this IHtmlHelper htmlHelper, - [NotNull] string partialViewName, ViewDataDictionary viewData) + public static Task RenderPartialAsync( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] string partialViewName, + ViewDataDictionary viewData) { return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData); } @@ -86,13 +89,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Renders the partial view with an empty view data and the given model. /// - /// The of the model. /// The instance that this method extends. /// The name of the partial view to render. /// The model to provide to the partial view that will be rendered. /// A that represents when rendering has completed. - public static Task RenderPartialAsync([NotNull] this IHtmlHelper htmlHelper, - [NotNull] string partialViewName, object model) + public static Task RenderPartialAsync( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] string partialViewName, + object model) { return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs index 02384df28c..83e007a10f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs @@ -6,31 +6,38 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class SelectExtensions { - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name) { return htmlHelper.DropDownList(name, selectList: null, optionLabel: null, htmlAttributes: null); } - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, - string optionLabel) + public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, string optionLabel) { return htmlHelper.DropDownList(name, selectList: null, optionLabel: optionLabel, htmlAttributes: null); } - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, + public static HtmlString DropDownList( + [NotNull] this IHtmlHelper htmlHelper, + string name, IEnumerable selectList) { return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: null); } - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, - IEnumerable selectList, object htmlAttributes) + public static HtmlString DropDownList( + [NotNull] this IHtmlHelper htmlHelper, + string name, + IEnumerable selectList, + object htmlAttributes) { return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: htmlAttributes); } - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, - IEnumerable selectList, string optionLabel) + public static HtmlString DropDownList( + [NotNull] this IHtmlHelper htmlHelper, + string name, + IEnumerable selectList, + string optionLabel) { return htmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes: null); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs index cf97f71ef6..c441b852e2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs @@ -4,46 +4,53 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperValidationExtensions { - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper) + public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper) { return ValidationSummary(htmlHelper, excludePropertyErrors: false); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - bool excludePropertyErrors) + public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors) { return ValidationSummary(htmlHelper, excludePropertyErrors, message: null); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - string message) + public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message) { return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message, htmlAttributes: (object)null); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - bool excludePropertyErrors, string message) + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, + bool excludePropertyErrors, + string message) { return ValidationSummary(htmlHelper, excludePropertyErrors, message, htmlAttributes: (object)null); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - string message, object htmlAttributes) + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, + string message, + object htmlAttributes) { return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message, htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - bool excludePropertyErrors, string message, object htmlAttributes) + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, + bool excludePropertyErrors, + string message, + object htmlAttributes) { return htmlHelper.ValidationSummary(excludePropertyErrors, message, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); } - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, - string message, IDictionary htmlAttributes) + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, + string message, + IDictionary htmlAttributes) { return htmlHelper.ValidationSummary(excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes); diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs index 9a3719354d..ccbf780bf2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs @@ -5,22 +5,24 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class HtmlHelperValueExtensions { - public static HtmlString Value([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString Value([NotNull] this IHtmlHelper htmlHelper, string name) { return htmlHelper.Value(name, format: null); } - public static HtmlString ValueFor([NotNull] this IHtmlHelper htmlHelper, Expression> expression) + public static HtmlString ValueFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.ValueFor(expression, format: null); } - public static HtmlString ValueForModel([NotNull] this IHtmlHelper htmlHelper) + public static HtmlString ValueForModel([NotNull] this IHtmlHelper htmlHelper) { - return ValueForModel(htmlHelper, format: null); + return ValueForModel(htmlHelper, format: null); } - public static HtmlString ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format) + public static HtmlString ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format) { return htmlHelper.Value(string.Empty, format); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs new file mode 100644 index 0000000000..65f4dc7ca1 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs @@ -0,0 +1,358 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNet.Mvc.Rendering +{ + /// + /// Base HTML helpers. + /// + public interface IHtmlHelper + { + /// + /// Gets or sets the character that replaces periods in the ID attribute of an element. + /// + string IdAttributeDotReplacement { get; set; } + + /// + /// Gets the view bag. + /// + dynamic ViewBag { get; } + + /// + /// Gets the context information about the view. + /// + ViewContext ViewContext { get; } + + /// + /// Gets the current view data. + /// + ViewDataDictionary ViewData { get; } + + /// + /// Returns an anchor element (a element) that contains a URL path to the specified action. + /// + /// The inner text of the anchor element. + /// The name of the action. + /// The name of the controller. + /// The protocol for the URL, such as "http" or "https". + /// The host name for the URL. + /// The URL fragment name (the anchor name). + /// + /// An object that contains the parameters for a route. The parameters are retrieved through reflection by + /// examining the properties of the object. This object is typically created using object initializer syntax. + /// Alternatively, an instance containing the route parameters. + /// + /// + /// An object that contains the HTML attributes to set for the element. Alternatively, an + /// instance containing the HTML attributes. + /// + /// + /// An anchor element (a element). + /// + HtmlString ActionLink( + [NotNull] string linkText, + string actionName, + string controllerName, + string protocol, + string hostname, + string fragment, + object routeValues, + object htmlAttributes); + + /// + /// Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. + /// + /// + /// The generated form field (anti-forgery token). + /// + HtmlString AntiForgeryToken(); + + /// + /// Writes an opening tag to the response. When the user submits the form, + /// the request will be processed by an action method. + /// + /// The name of the action method. + /// The name of the controller. + /// An object that contains the parameters for a route. The parameters are retrieved + /// through reflection by examining the properties of the object. This object is typically created using object + /// initializer syntax. Alternatively, an instance containing the + /// route parameters. + /// The HTTP method for processing the form, either GET or POST. + /// An object that contains the HTML attributes to set for the element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// An instance which emits the closing {form} tag when disposed. + MvcForm BeginForm( + string actionName, + string controllerName, + object routeValues, + FormMethod method, + object htmlAttributes); + + /// + /// Render an input element of type "checkbox" with value "true" and an input element of type "hidden" with + /// value "false". + /// + /// + /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data + /// only if value is not in submitted data and is null. + /// + /// + /// If true, checkbox is initially checked. Ignore if named value is found in submitted data. Finally + /// fall back to an existing "checked" value in . + /// + /// An object that contains the HTML attributes to set for the element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// New containing the rendered HTML. + HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes); + + /// + /// Returns HTML markup for each property in the object that is represented by the expression, using the + /// specified template, HTML field ID, and additional view data. + /// + /// An expression that identifies the object that contains the properties to display. + /// + /// 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 object that is represented by the expression. + HtmlString Display( + string expression, + string templateName, + 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. + /// + /// An expression that identifies the object that contains the display name. + /// + /// The display name. + /// + HtmlString DisplayName(string expression); + + /// + /// Returns a single-selection HTML {select} element using the specified name of the form field, + /// list items, option label, and HTML attributes. + /// + /// The name of the form field to return. + /// A collection of objects that are used to populate the + /// drop-down list. + /// The text for a default empty item. This parameter can be null. + /// An object that contains the HTML attributes to set for the {select} element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// An HTML {select} element with an {option} subelement for each item in the list. + HtmlString DropDownList( + string name, + IEnumerable selectList, + string optionLabel, + object htmlAttributes); + + /// + /// Converts the value of the specified object to an HTML-encoded string. + /// + /// The object to encode. + /// The HTML-encoded string. + string Encode(object value); + + /// + /// Converts the specified string to an HTML-encoded string. + /// + /// The string to encode. + /// The HTML-encoded string. + string Encode(string value); + + /// + /// Renders the closing tag to the response. + /// + void EndForm(); + + /// + /// Formats the value. + /// + /// The value. + /// The format string. + /// The formatted value. + string FormatValue(object value, string format); + + /// + /// Creates an HTML element ID using the specified element name. + /// + /// The name of the HTML element. + /// The ID of the HTML element. + string GenerateIdFromName(string name); + + /// + /// Render an input element of type "hidden". + /// + /// + /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data + /// only if value is not in submitted data and is null. + /// + /// + /// If non-null, value to include in the element. Ignore if named value is found in submitted data. + /// + /// An object that contains the HTML attributes to set for the element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// New containing the rendered HTML. + HtmlString Hidden(string name, object value, object htmlAttributes); + + /// + /// Returns an HTML label element and the property name of the property that is represented by the specified + /// expression. + /// + /// An expression that identifies the property to display. + /// The label text. + /// An object that contains the HTML attributes to set for the element. + /// + /// An HTML label element and the property name of the property that is represented by the expression. + /// + HtmlString Label(string expression, string labelText, object htmlAttributes); + + /// + /// Gets the full HTML field name for the given expression . + /// + /// Name of an expression, relative to the current model. + /// An that represents HTML markup. + HtmlString Name(string name); + + /// + /// Returns a partial view in string format. + /// + /// The name of the partial view to render and return. + /// A model to pass into the partial view. + /// A to pass into the partial view. + /// A task that represents when rendering of the partial view into a string has completed. + Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); + + /// + /// Render an input element of type "password". + /// + /// + /// Rendered element's name. Also use this name to find value in view data. Use view data + /// only if value is not in submitted data and is null. + /// + /// + /// If non-null, value to include in the element. + /// + /// An object that contains the HTML attributes to set for the element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// New containing the rendered HTML. + HtmlString Password(string name, object value, object htmlAttributes); + + /// + /// Render an input element of type "radio". + /// + /// + /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data + /// only if value is not in submitted data and is null. + /// + /// + /// If non-null, value to include in the element. May be null only if + /// is also null. Also compared to value in submitted data or view data to + /// determine if that parameter is null. Ignore if named value is found in + /// submitted data. + /// + /// + /// If true, radio button is initially selected. Ignore if named value is found in submitted data. Fall + /// back to comparing with view data if this parameter is null. Finally + /// fall back to an existing "checked" value in . + /// + /// An object that contains the HTML attributes to set for the element. + /// Alternatively, an instance containing the HTML attributes. + /// + /// New containing the rendered HTML. + HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes); + + /// + /// Wraps HTML markup in an , which will enable HTML markup to be + /// rendered to the output without getting HTML encoded. + /// + /// HTML markup string. + /// An that represents HTML markup. + HtmlString Raw(string value); + + /// + /// Wraps HTML markup from the string representation of an object in an , + /// which will enable HTML markup to be rendered to the output without getting HTML encoded. + /// + /// object with string representation as HTML markup. + /// An that represents HTML markup. + HtmlString Raw(object value); + + /// + /// Renders a partial view. + /// + /// The name of the partial view to render. + /// A model to pass into the partial view. + /// A to pass into the partial view. + /// A task that represents when rendering has completed. + Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); + + /// + /// Render an input element of type "text". + /// + /// + /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data + /// only if value is not in submitted data and is null. + /// + /// + /// If non-null, value to include in the element. Ignore if named value is found in submitted data. + /// + /// + /// + /// containing additional HTML attributes. + /// + /// New containing the rendered HTML. + HtmlString TextBox(string name, object value, string format, IDictionary htmlAttributes); + + /// + /// Returns an unordered list (ul element) of validation messages that are in the + /// object. + /// + /// true to have the summary display model-level errors only, or false to + /// have the summary display all errors. + /// The message to display with the validation summary. + /// A dictionary that contains the HTML attributes for the element. + /// An that contains an unordered list (ul element) of validation messages. + /// + HtmlString ValidationSummary( + bool excludePropertyErrors, + string message, + IDictionary htmlAttributes); + + /// + /// Returns the model value for the given expression . + /// + /// Name of an expression, relative to the current model. + /// The optional format string to apply to the value. + /// An that represents HTML markup. + HtmlString Value([NotNull] string name, string format); + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs index 52de3af3bc..b596fc34c3 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; -using System.Threading.Tasks; namespace Microsoft.AspNet.Mvc.Rendering { @@ -9,107 +8,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An for Linq expressions. /// /// The of the model. - public interface IHtmlHelper + public interface IHtmlHelper : IHtmlHelper { - /// - /// Gets or sets the character that replaces periods in the ID attribute of an element. - /// - string IdAttributeDotReplacement { get; set; } - - /// - /// Gets the view bag. - /// - dynamic ViewBag { get; } - - /// - /// Gets the context information about the view. - /// - ViewContext ViewContext { get; } - /// /// Gets the current view data. /// - ViewDataDictionary ViewData { get; } - - /// - /// Returns an anchor element (a element) that contains a URL path to the specified action. - /// - /// The inner text of the anchor element. - /// The name of the action. - /// The name of the controller. - /// The protocol for the URL, such as "http" or "https". - /// The host name for the URL. - /// The URL fragment name (the anchor name). - /// - /// An object that contains the parameters for a route. The parameters are retrieved through reflection by - /// examining the properties of the object. This object is typically created using object initializer syntax. - /// Alternatively, an instance containing the route parameters. - /// - /// - /// An object that contains the HTML attributes to set for the element. Alternatively, an - /// instance containing the HTML attributes. - /// - /// - /// An anchor element (a element). - /// - HtmlString ActionLink( - [NotNull] string linkText, - string actionName, - string controllerName, - string protocol, - string hostname, - string fragment, - object routeValues, - object htmlAttributes); - - /// - /// Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. - /// - /// - /// The generated form field (anti-forgery token). - /// - HtmlString AntiForgeryToken(); - - /// - /// Writes an opening
tag to the response. When the user submits the form, - /// the request will be processed by an action method. - ///
- /// The name of the action method. - /// The name of the controller. - /// An object that contains the parameters for a route. The parameters are retrieved - /// through reflection by examining the properties of the object. This object is typically created using object - /// initializer syntax. Alternatively, an instance containing the - /// route parameters. - /// The HTTP method for processing the form, either GET or POST. - /// An object that contains the HTML attributes to set for the element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// An instance which emits the closing {form} tag when disposed. - MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, - object htmlAttributes); - - /// - /// Renders the closing tag to the response. - /// - void EndForm(); - - /// - /// Render an input element of type "checkbox" with value "true" and an input element of type "hidden" with - /// value "false". - /// - /// - /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data - /// only if value is not in submitted data and is null. - /// - /// - /// If true, checkbox is initially checked. Ignore if named value is found in submitted data. Finally - /// fall back to an existing "checked" value in . - /// - /// An object that contains the HTML attributes to set for the element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// New containing the rendered HTML. - HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes); + new ViewDataDictionary ViewData { get; } /// /// Render an input element of type "checkbox" with value "true" and an input element of type "hidden" with @@ -125,71 +29,27 @@ namespace Microsoft.AspNet.Mvc.Rendering HtmlString CheckBoxFor([NotNull] Expression> expression, object htmlAttributes); /// - /// Returns HTML markup for each property in the object that is represented by the expression, using the specified - /// template, HTML field ID, and additional view data. - /// - /// An expression that identifies the object that contains the properties to display. - /// 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 object that is represented by the expression. - HtmlString Display(string expression, - string templateName, - string htmlFieldName, - object additionalViewData); - - /// - /// Returns HTML markup for each property in the object that is represented by the specified expression, using the - /// template, an HTML field ID, and additional view data. + /// Returns HTML markup for each property in the object that is represented by the specified expression, using + /// the template, an HTML field ID, and additional view data. /// /// The type of the value. - /// An expression that identifies the object that contains the properties to display. + /// An expression that identifies the object that contains the properties to display. + /// /// 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. + /// 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 + /// 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 object that is represented by the expression. - HtmlString DisplayFor(Expression> expression, + HtmlString DisplayFor([NotNull] Expression> expression, string templateName, 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. - /// - /// An expression that identifies the object that contains the display name. - /// - /// The display name. - /// - HtmlString DisplayName(string expression); - /// /// Gets the display name for the model. /// @@ -198,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// The display name for the model. /// - HtmlString DisplayNameFor(Expression> expression); + HtmlString DisplayNameFor([NotNull] Expression> expression); /// /// Gets the display name for the inner model if the current model represents a collection. @@ -207,25 +67,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The type of the value. /// An expression that identifies the object that contains the display name. /// The display name for the inner model. - HtmlString DisplayNameForInnerType(Expression> expression); - - /// - /// Returns a single-selection HTML {select} element using the specified name of the form field, - /// list items, option label, and HTML attributes. - /// - /// The name of the form field to return. - /// A collection of objects that are used to populate the - /// drop-down list. - /// The text for a default empty item. This parameter can be null. - /// An object that contains the HTML attributes to set for the {select} element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// An HTML {select} element with an {option} subelement for each item in the list. - HtmlString DropDownList( - string name, - IEnumerable selectList, - string optionLabel, - object htmlAttributes); + HtmlString DisplayNameForInnerType( + [NotNull] Expression> expression); /// /// Returns a single-selection HTML {select} element for the object that is represented @@ -246,51 +89,6 @@ namespace Microsoft.AspNet.Mvc.Rendering string optionLabel, object htmlAttributes); - /// - /// Converts the value of the specified object to an HTML-encoded string. - /// - /// The object to encode. - /// The HTML-encoded string. - string Encode(object value); - - /// - /// Converts the specified string to an HTML-encoded string. - /// - /// The string to encode. - /// The HTML-encoded string. - string Encode(string value); - - /// - /// Formats the value. - /// - /// The value. - /// The format string. - /// The formatted value. - string FormatValue(object value, string format); - - /// - /// Creates an HTML element ID using the specified element name. - /// - /// The name of the HTML element. - /// The ID of the HTML element. - string GenerateIdFromName(string name); - - /// - /// Render an input element of type "hidden". - /// - /// - /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data - /// only if value is not in submitted data and is null. - /// - /// - /// If non-null, value to include in the element. Ignore if named value is found in submitted data. - /// - /// An object that contains the HTML attributes to set for the element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// New containing the rendered HTML. - HtmlString Hidden(string name, object value, object htmlAttributes); - /// /// Render an input element of type "hidden". /// @@ -305,36 +103,19 @@ namespace Microsoft.AspNet.Mvc.Rendering object htmlAttributes); /// - /// Returns an HTML label element and the property name of the property that is represented by the specified expression. - /// - /// An expression that identifies the property to display. - /// The label text. - /// An object that contains the HTML attributes to set for the element. - /// - /// An HTML label element and the property name of the property that is represented by the expression. - /// - HtmlString Label(string expression, string labelText, object htmlAttributes); - - /// - /// Returns an HTML label element and the property name of the property that is represented by the specified expression. + /// Returns an HTML label element and the property name of the property that is represented by the specified + /// expression. /// /// An expression that identifies the property to display. /// An object that contains the HTML attributes to set for the element. - /// The type of the value. + /// The type of the value. /// /// An HTML label element and the property name of the property that is represented by the expression. /// - HtmlString LabelFor(Expression> expression, + HtmlString LabelFor([NotNull] Expression> expression, string labelText, object htmlAttributes); - /// - /// Gets the full HTML field name for the given expression . - /// - /// Name of an expression, relative to the current model. - /// An that represents HTML markup. - HtmlString Name(string name); - /// /// Gets the full HTML field name for the given . /// @@ -343,22 +124,6 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that represents HTML markup. HtmlString NameFor([NotNull] Expression> expression); - /// - /// Render an input element of type "password". - /// - /// - /// Rendered element's name. Also use this name to find value in view data. Use view data - /// only if value is not in submitted data and is null. - /// - /// - /// If non-null, value to include in the element. - /// - /// An object that contains the HTML attributes to set for the element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// New containing the rendered HTML. - HtmlString Password(string name, object value, object htmlAttributes); - /// /// Render an input element of type "password". /// @@ -372,30 +137,6 @@ namespace Microsoft.AspNet.Mvc.Rendering HtmlString PasswordFor([NotNull] Expression> expression, object htmlAttributes); - /// - /// Render an input element of type "radio". - /// - /// - /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data - /// only if value is not in submitted data and is null. - /// - /// - /// If non-null, value to include in the element. May be null only if - /// is also null. Also compared to value in submitted data or view data to - /// determine if that parameter is null. Ignore if named value is found in - /// submitted data. - /// - /// - /// If true, radio button is initially selected. Ignore if named value is found in submitted data. Fall - /// back to comparing with view data if this parameter is null. Finally - /// fall back to an existing "checked" value in . - /// - /// An object that contains the HTML attributes to set for the element. - /// Alternatively, an instance containing the HTML attributes. - /// - /// New containing the rendered HTML. - HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes); - /// /// Render an input element of type "radio". /// @@ -413,57 +154,6 @@ namespace Microsoft.AspNet.Mvc.Rendering HtmlString RadioButtonFor([NotNull] Expression> expression, object value, object htmlAttributes); - /// - /// Wraps HTML markup in an , which will enable HTML markup to be - /// rendered to the output without getting HTML encoded. - /// - /// HTML markup string. - /// An that represents HTML markup. - HtmlString Raw(string value); - - /// - /// Wraps HTML markup from the string representation of an object in an , - /// which will enable HTML markup to be rendered to the output without getting HTML encoded. - /// - /// object with string representation as HTML markup. - /// An that represents HTML markup. - HtmlString Raw(object value); - - /// - /// Returns a partial view in string format. - /// - /// The name of the partial view to render and return. - /// A model to pass into the partial view. - /// A to pass into the partial view. - /// A task that represents when rendering of the partial view into a string has completed. - Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); - - /// - /// Renders a partial view. - /// - /// The name of the partial view to render. - /// A model to pass into the partial view. - /// A to pass into the partial view. - /// A task that represents when rendering has completed. - Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); - - /// - /// Render an input element of type "text". - /// - /// - /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data - /// only if value is not in submitted data and is null. - /// - /// - /// If non-null, value to include in the element. Ignore if named value is found in submitted data. - /// - /// - /// - /// containing additional HTML attributes. - /// - /// New containing the rendered HTML. - HtmlString TextBox(string name, object value, string format, IDictionary htmlAttributes); - /// /// Render an input element of type "text". /// @@ -478,27 +168,6 @@ namespace Microsoft.AspNet.Mvc.Rendering HtmlString TextBoxFor([NotNull] Expression> expression, string format, IDictionary htmlAttributes); - /// - /// Returns an unordered list (ul element) of validation messages that are in the - /// object. - /// - /// true to have the summary display model-level errors only, or false to - /// have the summary display all errors. - /// The message to display with the validation summary. - /// A dictionary that contains the HTML attributes for the element. - /// An that contains an unordered list (ul element) of validation messages. - /// - HtmlString ValidationSummary(bool excludePropertyErrors, string message, - IDictionary htmlAttributes); - - /// - /// Returns the model value for the given expression . - /// - /// Name of an expression, relative to the current model. - /// The optional format string to apply to the value. - /// An that represents HTML markup. - HtmlString Value([NotNull] string name, string format); - /// /// Returns the model value for the given expression . /// diff --git a/src/Microsoft.AspNet.Mvc/MvcServices.cs b/src/Microsoft.AspNet.Mvc/MvcServices.cs index d732d40b78..15437c435c 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServices.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServices.cs @@ -9,7 +9,6 @@ using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor.Compilation; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Security.Authorization; -using Microsoft.AspNet.Security.DataProtection; namespace Microsoft.AspNet.Mvc { @@ -97,6 +96,7 @@ namespace Microsoft.AspNet.Mvc implementationInstance: null, lifecycle: LifecycleKind.Transient); + yield return describe.Transient(); yield return describe.Describe( typeof(IHtmlHelper<>),