// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { private static Func CombineSelectors(Func selector1, Func selector2) { if (selector1.Target is ICombinedSelectors c) { return c.Combine(selector2).Invoke; } else { return new CombinedSelectors2(selector1, selector2).Invoke; } } private interface ICombinedSelectors { ICombinedSelectors Combine(Func selector); TResult Invoke(TSource x); } private static Func> CombineSelectors(Func> selector1, Func> selector2) { if (selector1.Target is ICombinedAsyncSelectors c) { return c.Combine(selector2).Invoke; } else { return new CombinedAsyncSelectors2(selector1, selector2).Invoke; } } private interface ICombinedAsyncSelectors { ICombinedAsyncSelectors Combine(Func> selector); ValueTask Invoke(TSource x); } #if !NO_DEEP_CANCELLATION private static Func> CombineSelectors(Func> selector1, Func> selector2) { if (selector1.Target is ICombinedAsyncSelectorsWithCancellation c) { return c.Combine(selector2).Invoke; } else { return new CombinedAsyncSelectorsWithCancellation2(selector1, selector2).Invoke; } } private interface ICombinedAsyncSelectorsWithCancellation { ICombinedAsyncSelectorsWithCancellation Combine(Func> selector); ValueTask Invoke(TSource x, CancellationToken ct); } #endif } }