这么做还是有一些意义的,避免重复处理Task<IAsyncEnumerable>实在是有些复杂,如果代码还要处理IAsyncEnumerable的话尤为如此,将二者统一还是有一定意义的
#region AsAsyncEnumerable public static async IAsyncEnumerable<T> AsAsyncEnumerable<T>(this System.Threading.Tasks.ValueTask<IAsyncEnumerable<T>> asyncEnumerable) { await foreach (var one in await asyncEnumerable.ConfigureAwait(false)) { yield return one; } } public static async IAsyncEnumerable<T> AsAsyncEnumerable<T>(this System.Threading.Tasks.ValueTask<IEnumerable<T>> asyncEnumerable) { foreach (var one in await asyncEnumerable.ConfigureAwait(false)) { yield return one; } } public static async IAsyncEnumerable<T> AsAsyncEnumerable<T>(this System.Threading.Tasks.Task<IEnumerable<T>> asyncEnumerable) { foreach (var one in await asyncEnumerable.ConfigureAwait(false)) { yield return one; } } public static async IAsyncEnumerable<T> AsAsyncEnumerable<T>(this System.Threading.Tasks.Task<IAsyncEnumerable<T>> asyncEnumerable) { await foreach(var one in await asyncEnumerable.ConfigureAwait(false)) { yield return one; } } #endregion