mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-03-13 03:10:39 +00:00
IAsyncEnumerable
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.2" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" PrivateAssets="all" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
|
||||
@@ -1362,7 +1362,36 @@ partial class DistributedConnection
|
||||
return;
|
||||
}
|
||||
|
||||
if (rt is System.Collections.IEnumerable && !(rt is Array || rt is Map<string, object> || rt is string))
|
||||
if (rt is IAsyncEnumerable<object>)
|
||||
{
|
||||
var enu = rt as IAsyncEnumerable<object>;
|
||||
var enumerator = enu.GetAsyncEnumerator();
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (await enumerator.MoveNextAsync())
|
||||
{
|
||||
var v = enumerator.Current;
|
||||
SendChunk(callback, v);
|
||||
}
|
||||
|
||||
SendReply(IIPPacketReply.Completed, callback);
|
||||
|
||||
if (context != null)
|
||||
context.Ended = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (context != null)
|
||||
context.Ended = true;
|
||||
|
||||
var (code, msg) = SummerizeException(ex);
|
||||
SendError(ErrorType.Exception, callback, code, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (rt is System.Collections.IEnumerable && !(rt is Array || rt is Map<string, object> || rt is string))
|
||||
{
|
||||
var enu = rt as System.Collections.IEnumerable;
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class FunctionTemplate : MemberTemplate
|
||||
{
|
||||
rtType = TRU.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
}
|
||||
else if (genericRtType == typeof(IEnumerable<>))// || genericRtType == typeof(IAsyncEnumerable<>))
|
||||
else if (genericRtType == typeof(IEnumerable<>) || genericRtType == typeof(IAsyncEnumerable<>))
|
||||
{
|
||||
// get export
|
||||
rtType = TRU.FromType(mi.ReturnType.GetGenericArguments()[0]);
|
||||
|
||||
Reference in New Issue
Block a user