/// <summary> /// See if this enumeration has all items in passed enumeration. Returns true if passed enum is empty. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public async static Task <bool> ContainsAllItems <T>(this IAsyncEnumerable <T> a, IAsyncEnumerable <T> b) { if (!await b.Any()) { return(true); } return(!await b.Except(a).Any()); }
public static Task <bool> Contains <TSource>(this IAsyncEnumerable <TSource> source, TSource value, IEqualityComparer <TSource> comparer, CancellationToken cancellationToken) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (comparer == null) { throw new ArgumentNullException(nameof(comparer)); } return(source.Any(x => comparer.Equals(x, value), cancellationToken)); }
private static async Task <bool> IsEmpty_ <TSource>(IAsyncEnumerable <TSource> source, CancellationToken cancellationToken) { return(!await source.Any(cancellationToken) .ConfigureAwait(false)); }
private static Task <bool> AnyAsyncShim <TSource>(IAsyncEnumerable <TSource> source) { return(source.Any()); }