using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.TagHelpers; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; using System.Collections; namespace zero.TagHelpers; public abstract class BaseSelectTagHelper : TagHelper { protected const string FOR_ATTRIBUTE_NAME = "asp-for"; protected bool AllowMultiple; protected ICollection CurrentValues; protected BaseSelectTagHelper(IHtmlGenerator generator) { Generator = generator; } /// /// Gets the used to generate the 's output. /// protected IHtmlGenerator Generator { get; } /// /// Gets the of the executing view. /// [HtmlAttributeNotBound] [ViewContext] public ViewContext ViewContext { get; set; } /// /// An expression to be evaluated against the current model. /// [HtmlAttributeName(FOR_ATTRIBUTE_NAME)] public ModelExpression For { get; set; } /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. /// public List Items { get; set; } = new List(); /// /// The name of the <input> element. /// /// /// Passed through to the generated HTML in all cases. Also used to determine whether is /// valid with an empty . /// public string Name { get; set; } /// public override void Init(TagHelperContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (For == null) { // Informs contained elements that they're running within a targeted