/// <summary>
        ///     Initializes a new instance of the <see cref="FromQueryWithAlternateNamesAttribute" /> class.
        /// </summary>
        /// <param name="alternateNames">
        ///     The alternate names.  The first one is used as the default in
        ///     <see cref="FromQueryAttribute" />
        /// </param>
        public FromQueryWithAlternateNamesAttribute(params string[] alternateNames)
        {
            Name = alternateNames is not null && alternateNames.Length > 0
                ? alternateNames[0]
                : throw new ArgumentNullException(nameof(alternateNames),
                                                  "You must at least specify the default name!  However if you are not using " +
                                                  $"alternates then you should consider using the {nameof(FromQueryAttribute)} instead."
                                                  );

            foreach (var an in alternateNames)
            {
                if (AlternateNames.Any(s => s.EqualsEx(an)))
                {
                    continue;
                }

                AlternateNames.Add(an);
            }
        }
示例#2
0
 public bool MatchesName(string match)
 {
     return(String.Compare(match, Name, true) == 0 ||
            String.Compare(match, ShortName, true) == 0 ||
            AlternateNames.Any(name => String.Compare(match, name, true) == 0));
 }