From 2fd51c82f9d3bec9ffa3aeedbf58f6172170142a Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Fri, 17 Oct 2014 14:49:54 -0700 Subject: [PATCH] Add ` element. Just make sure Items wasn't specified. + if (Items != null) + { + var message = Resources.FormatSelectTagHelper_CannotDetermineContentWhenOnlyItemsSpecified( + "", + nameof(For).ToLowerInvariant(), + nameof(IModelMetadataProvider), + For.Name)); + } + + bool allowMultiple; + if (string.IsNullOrEmpty(Multiple)) + { + // Base allowMultiple on the instance or declared type of the expression. + var realModelType = For.Metadata.RealModelType; + allowMultiple = + typeof(string) != realModelType && typeof(IEnumerable).IsAssignableFrom(realModelType); + } + else if (string.Equals(Multiple, "multiple", StringComparison.OrdinalIgnoreCase)) + { + allowMultiple = true; + + // Copy exact attribute name and value the user entered. Must be done prior to any copying from a + // TagBuilder. Not done in next case because "true" and "false" aren't valid for the HTML 5 + // attribute. + output.CopyHtmlAttribute(nameof(Multiple), context); + } + else if (!bool.TryParse(Multiple.ToLowerInvariant(), out allowMultiple)) + { + throw new InvalidOperationException(Resources.FormatTagHelpers_InvalidValue_ThreeAcceptableValues( + "