using System; using System.Collections.Generic; namespace Jellyfin.Extensions; /// /// Static extensions for the interface. /// public static class EnumerableExtensions { /// /// Determines whether the value is contained in the source collection. /// /// An instance of the interface. /// The value to look for in the collection. /// The string comparison. /// A value indicating whether the value is contained in the collection. /// The source is null. public static bool Contains(this IEnumerable source, ReadOnlySpan value, StringComparison stringComparison) { ArgumentNullException.ThrowIfNull(source); if (source is IList list) { int len = list.Count; for (int i = 0; i < len; i++) { if (value.Equals(list[i], stringComparison)) { return true; } } return false; } foreach (string element in source) { if (value.Equals(element, stringComparison)) { return true; } } return false; } /// /// Gets an IEnumerable from a single item. /// /// The item to return. /// The type of item. /// The IEnumerable{T}. public static IEnumerable SingleItemAsEnumerable(this T item) { yield return item; } }