From 663f6a1718447e46dbbfa868c4017000d767107e Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 2 Aug 2016 15:46:57 -0700 Subject: [PATCH] Expose `GetInputType` as a protected member of `InputTagHelper`. - Added doc comments. #4979 --- .../InputTagHelper.cs | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs index d386020418..48a457e495 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs @@ -230,6 +230,30 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers } } + /// + /// Gets an <input> element's "type" attribute value based on the given + /// or . + /// + /// The to use. + /// When this method returns, contains the string, often the name of a + /// base class, used to determine this method's return value. + /// An <input> element's "type" attribute value. + protected string GetInputType(ModelExplorer modelExplorer, out string inputTypeHint) + { + foreach (var hint in GetInputTypeHints(modelExplorer)) + { + string inputType; + if (_defaultInputTypes.TryGetValue(hint, out inputType)) + { + inputTypeHint = hint; + return inputType; + } + } + + inputTypeHint = InputType.Text.ToString().ToLowerInvariant(); + return inputTypeHint; + } + private void GenerateCheckBox(ModelExplorer modelExplorer, TagHelperOutput output) { if (typeof(bool) != modelExplorer.ModelType) @@ -371,22 +395,6 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers return format; } - private string GetInputType(ModelExplorer modelExplorer, out string inputTypeHint) - { - foreach (var hint in GetInputTypeHints(modelExplorer)) - { - string inputType; - if (_defaultInputTypes.TryGetValue(hint, out inputType)) - { - inputTypeHint = hint; - return inputType; - } - } - - inputTypeHint = InputType.Text.ToString().ToLowerInvariant(); - return inputTypeHint; - } - // A variant of TemplateRenderer.GetViewNames(). Main change relates to bool? handling. private static IEnumerable GetInputTypeHints(ModelExplorer modelExplorer) {