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)
{
if (source == null)
{
throw new ArgumentNullException(nameof(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;
}
}
}