Beispiel #1
0
        public bool IsReleaseTypeOf(string type, bool doCheckTitles = false)
        {
            if (string.IsNullOrEmpty(type))
            {
                return(false);
            }
            try
            {
                if (doCheckTitles)
                {
                    if (Artist != null && !string.IsNullOrEmpty(Artist.Name))
                    {
                        if (Artist.Name.IndexOf(type, 0, StringComparison.OrdinalIgnoreCase) > -1)
                        {
                            return(true);
                        }
                    }
                    if (!string.IsNullOrEmpty(Title))
                    {
                        if (Title.IndexOf(type, 0, StringComparison.OrdinalIgnoreCase) > -1)
                        {
                            return(true);
                        }
                    }
                    if (AlternateNames != null)
                    {
                        if (AlternateNames.IsValueInDelimitedList(type))
                        {
                            return(true);
                        }
                    }
                }

                if (Tags != null)
                {
                    if (Tags.IsValueInDelimitedList(type))
                    {
                        return(true);
                    }
                }
                if (Genres != null)
                {
                    if (Genres.Any(x => x.Genre.Name.ToLower().Equals(type)))
                    {
                        return(true);
                    }
                }
            }
            catch
            {
            }

            return(false);
        }
        /// <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);
            }
        }
Beispiel #3
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));
 }