исключения теперь вылетают и по сети
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj" OutputItemType="Analyzer"
|
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj"
|
||||||
|
OutputItemType="Analyzer"
|
||||||
ReferenceOutputAssembly="false"/>
|
ReferenceOutputAssembly="false"/>
|
||||||
<ProjectReference Include="..\mROA\mROA.csproj" />
|
<ProjectReference Include="..\mROA\mROA.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Этот код создан программой.
|
// This code was generated by a tool.
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
//
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// повторной генерации кода.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Codegen")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("YaslePoy")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.4.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d780d0ea0b8c501b99358c1e89abc9fa4c46f959")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.4+f7341269329d5c55e14b1f5149986c2d97cad020")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5bcdb968f0f857381cbf8b7f5ee99b5e8a5f6b36")]
|
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Codegen")]
|
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Codegen")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Codegen")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Codegen")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.4.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/YaslePoy/mROA")]
|
||||||
|
|
||||||
// Создано классом WriteCodeFragment MSBuild.
|
// Создано классом WriteCodeFragment MSBuild.
|
||||||
|
|
||||||
|
|||||||
@@ -5,18 +5,18 @@
|
|||||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mikhail\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mimm\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<SourceRoot Include="C:\Users\Mikhail\.nuget\packages\" />
|
<SourceRoot Include="C:\Users\Mimm\.nuget\packages\" />
|
||||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.codeanalysis.analyzers\3.3.4\buildTransitive\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codeanalysis.analyzers\3.3.4\buildTransitive\Microsoft.CodeAnalysis.Analyzers.props')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.codeanalysis.analyzers\3.3.4\buildTransitive\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codeanalysis.analyzers\3.3.4\buildTransitive\Microsoft.CodeAnalysis.Analyzers.props')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<PkgMicrosoft_CodeAnalysis_Analyzers Condition=" '$(PkgMicrosoft_CodeAnalysis_Analyzers)' == '' ">C:\Users\Mikhail\.nuget\packages\microsoft.codeanalysis.analyzers\3.3.4</PkgMicrosoft_CodeAnalysis_Analyzers>
|
<PkgMicrosoft_CodeAnalysis_Analyzers Condition=" '$(PkgMicrosoft_CodeAnalysis_Analyzers)' == '' ">C:\Users\Mimm\.nuget\packages\microsoft.codeanalysis.analyzers\3.3.4</PkgMicrosoft_CodeAnalysis_Analyzers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0b455b8dd8fd256581b224169026e33dad4a222b")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7341269329d5c55e14b1f5149986c2d97cad020")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+71e92f0301b2ba7aaaf7dca368a62bfba8554ca4")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7341269329d5c55e14b1f5149986c2d97cad020")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ build_property.PlatformNeutralAssembly =
|
|||||||
build_property.EnforceExtendedAnalyzerRules =
|
build_property.EnforceExtendedAnalyzerRules =
|
||||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
build_property.RootNamespace = mROA.Test
|
build_property.RootNamespace = mROA.Test
|
||||||
build_property.ProjectDir = C:\Users\Mikhail\Projects\VisualStudioProjects\mROA\mROA.Test\
|
build_property.ProjectDir = C:\Users\Mimm\Projects\VisualStudioProjects\mROA\mROA.Test\
|
||||||
build_property.EnableComHosting =
|
build_property.EnableComHosting =
|
||||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mikhail\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mimm\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<SourceRoot Include="C:\Users\Mikhail\.nuget\packages\" />
|
<SourceRoot Include="C:\Users\Mimm\.nuget\packages\" />
|
||||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
@@ -21,6 +21,6 @@
|
|||||||
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<PkgNUnit_Analyzers Condition=" '$(PkgNUnit_Analyzers)' == '' ">C:\Users\Mikhail\.nuget\packages\nunit.analyzers\4.6.0</PkgNUnit_Analyzers>
|
<PkgNUnit_Analyzers Condition=" '$(PkgNUnit_Analyzers)' == '' ">C:\Users\Mimm\.nuget\packages\nunit.analyzers\4.6.0</PkgNUnit_Analyzers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -43,70 +43,82 @@ public class BasicExecutionModule : IExecuteModule
|
|||||||
return Execute(currentCommand, context, parameter, command);
|
return Execute(currentCommand, context, parameter, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FinalCommandExecution Execute(MethodInfo currentCommand, object context, object? parameter,
|
private static ICommandExecution Execute(MethodInfo currentCommand, object context, object? parameter,
|
||||||
ICallRequest command)
|
ICallRequest command)
|
||||||
{
|
{
|
||||||
var finalResult = currentCommand.Invoke(context, parameter is null ? [] : [parameter]);
|
try
|
||||||
return new TypedFinalCommandExecution
|
|
||||||
{
|
{
|
||||||
CommandId = command.CommandId, Result = finalResult,
|
var finalResult = currentCommand.Invoke(context, parameter is null ? [] : [parameter]);
|
||||||
CallRequestId = command.CallRequestId,
|
return new TypedFinalCommandExecution
|
||||||
Type = currentCommand.ReturnType
|
{
|
||||||
};
|
CommandId = command.CommandId, Result = finalResult,
|
||||||
|
CallRequestId = command.CallRequestId,
|
||||||
|
Type = currentCommand.ReturnType
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new ExceptionCommandExecution
|
||||||
|
{
|
||||||
|
CallRequestId = command.CallRequestId, CommandId = command.CommandId,
|
||||||
|
Exeption = e.ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncCommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
private ICommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
||||||
ICallRequest command)
|
ICallRequest command)
|
||||||
{
|
{
|
||||||
var tokenSource = new CancellationTokenSource();
|
var tokenSource = new CancellationTokenSource();
|
||||||
var token = tokenSource.Token;
|
var token = tokenSource.Token;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = (Task)currentCommand.Invoke(context, parameter is null ? [token] : [parameter, token])!;
|
||||||
|
|
||||||
var result = (Task)currentCommand.Invoke(context, parameter is null ? [token] : [parameter, token])!;
|
|
||||||
var exec = new AsyncCommandExecution(tokenSource)
|
|
||||||
{ CommandId = command.CommandId, CallRequestId = command.CallRequestId };
|
|
||||||
|
|
||||||
result.ContinueWith(_ => { PostFinalizedCallback(exec, null); }, token);
|
result.Wait(token);
|
||||||
|
|
||||||
return exec;
|
|
||||||
|
return new FinalCommandExecution { CommandId = command.CommandId, CallRequestId = command.CallRequestId };
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new ExceptionCommandExecution
|
||||||
|
{
|
||||||
|
CallRequestId = command.CallRequestId, CommandId = command.CommandId,
|
||||||
|
Exeption = e.ToString()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncCommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
private ICommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
||||||
ICallRequest command)
|
ICallRequest command)
|
||||||
{
|
{
|
||||||
var tokenSource = new CancellationTokenSource();
|
var tokenSource = new CancellationTokenSource();
|
||||||
var token = tokenSource.Token;
|
var token = tokenSource.Token;
|
||||||
|
try
|
||||||
var result =
|
|
||||||
(Task)currentCommand.Invoke(context, parameter is null ? [token] : [parameter, token])!;
|
|
||||||
var exec = new AsyncCommandExecution(tokenSource)
|
|
||||||
{ CommandId = command.CommandId, CallRequestId = command.CallRequestId };
|
|
||||||
|
|
||||||
result.ContinueWith(task =>
|
|
||||||
{
|
{
|
||||||
try
|
var result =
|
||||||
|
(Task)currentCommand.Invoke(context, parameter is null ? [token] : [parameter, token])!;
|
||||||
|
|
||||||
|
result.Wait(token);
|
||||||
|
|
||||||
|
var finalResult = result.GetType().GetProperty("Result")?.GetValue(result);
|
||||||
|
return new TypedFinalCommandExecution
|
||||||
{
|
{
|
||||||
var finalResult = task.GetType().GetProperty("Result")?.GetValue(task);
|
CallRequestId = command.CallRequestId,
|
||||||
PostFinalizedCallback(exec, finalResult);
|
Result = result,
|
||||||
}
|
CommandId = command.CommandId,
|
||||||
catch (Exception e)
|
Type = finalResult.GetType()
|
||||||
{
|
};
|
||||||
_serialisationModule.PostResponse(new ExceptionCommandExecution {CallRequestId = exec.CallRequestId, CommandId = exec.CommandId, ClientId = exec.ClientId, Reason = e.InnerException.InnerException.ToString()});
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
|
|
||||||
}, token);
|
|
||||||
|
|
||||||
return exec;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PostFinalizedCallback(AsyncCommandExecution request, object? result)
|
|
||||||
{
|
|
||||||
_serialisationModule.PostResponse(new TypedFinalCommandExecution
|
|
||||||
{
|
{
|
||||||
CallRequestId = request.CallRequestId,
|
return new ExceptionCommandExecution
|
||||||
Result = result,
|
{
|
||||||
CommandId = request.CommandId,
|
CallRequestId = command.CallRequestId, CommandId = command.CommandId,
|
||||||
ClientId = request.ClientId,
|
Exeption = e.ToString()
|
||||||
Type = typeof(object)
|
};
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class JsonSerialisationModule : ISerialisationModule
|
|||||||
if (request.Parameter is not null)
|
if (request.Parameter is not null)
|
||||||
{
|
{
|
||||||
var parameter = _methodRepository.GetMethod(request.CommandId).GetParameters().First().ParameterType;
|
var parameter = _methodRepository.GetMethod(request.CommandId).GetParameters().First().ParameterType;
|
||||||
request.Parameter = (( JsonElement)request.Parameter).Deserialize(parameter);
|
request.Parameter = ((JsonElement)request.Parameter).Deserialize(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = _executeModule.Execute(request);
|
var response = _executeModule.Execute(request);
|
||||||
@@ -28,20 +28,23 @@ public class JsonSerialisationModule : ISerialisationModule
|
|||||||
|
|
||||||
public void PostResponse(ICommandExecution call)
|
public void PostResponse(ICommandExecution call)
|
||||||
{
|
{
|
||||||
var texted = string.Empty;
|
var texted = JsonSerializer.Serialize(call, call.GetType());
|
||||||
if (call is TypedFinalCommandExecution nonVoidCall)
|
// if (call is TypedFinalCommandExecution nonVoidCall)
|
||||||
{
|
// {
|
||||||
texted = JsonSerializer.Serialize(nonVoidCall);
|
// texted = JsonSerializer.Serialize(nonVoidCall);
|
||||||
}else if (call is FinalCommandExecution finalCommand)
|
// }
|
||||||
{
|
// else if (call is FinalCommandExecution finalCommand)
|
||||||
texted = JsonSerializer.Serialize(finalCommand);
|
// {
|
||||||
}else if (call is AsyncCommandExecution asyncCommand)
|
// texted = JsonSerializer.Serialize(finalCommand);
|
||||||
{
|
// }
|
||||||
texted = JsonSerializer.Serialize(asyncCommand);
|
// else if (call is AsyncCommandExecution asyncCommand)
|
||||||
}else if (call is ExceptionCommandExecution exeptionCommandExecution)
|
// {
|
||||||
{
|
// texted = JsonSerializer.Serialize(asyncCommand);
|
||||||
texted = JsonSerializer.Serialize(exeptionCommandExecution);
|
// }
|
||||||
}
|
// else if (call is ExceptionCommandExecution exceptionCommandExecution)
|
||||||
|
// {
|
||||||
|
// texted = JsonSerializer.Serialize(exceptionCommandExecution);
|
||||||
|
// }
|
||||||
|
|
||||||
var binary = Encoding.UTF8.GetBytes(texted);
|
var binary = Encoding.UTF8.GetBytes(texted);
|
||||||
_dataSource.SendTo(call.ClientId, binary);
|
_dataSource.SendTo(call.ClientId, binary);
|
||||||
|
|||||||
@@ -27,26 +27,5 @@ public class ExceptionCommandExecution : ICommandExecution
|
|||||||
public Guid CallRequestId { get; init; }
|
public Guid CallRequestId { get; init; }
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
public int CommandId { get; set; }
|
public int CommandId { get; set; }
|
||||||
public string Reason { get; set; }
|
public string Exeption { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class AsyncCommandExecution : ICommandExecution
|
|
||||||
{
|
|
||||||
public Guid CallRequestId { get; init; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public int ClientId { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public int CommandId { get; set; }
|
|
||||||
|
|
||||||
public void Cancel()
|
|
||||||
{
|
|
||||||
LocalToken.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CancellationTokenSource LocalToken;
|
|
||||||
|
|
||||||
public AsyncCommandExecution(CancellationTokenSource localToken)
|
|
||||||
{
|
|
||||||
LocalToken = localToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,14 @@ public class JsonFrontendSerialisationModule
|
|||||||
public async Task<FinalCommandExecution<T>> GetFinalCommandExecution<T>(Guid requestId)
|
public async Task<FinalCommandExecution<T>> GetFinalCommandExecution<T>(Guid requestId)
|
||||||
{
|
{
|
||||||
var receiveMessage = await _interactionModule.ReceiveMessage();
|
var receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
var str = Encoding.UTF8.GetString(receiveMessage);
|
// var str = Encoding.UTF8.GetString(receiveMessage);
|
||||||
var parsed = JsonSerializer.Deserialize<FinalCommandExecution<T>>(receiveMessage);
|
var document = JsonDocument.Parse(receiveMessage);
|
||||||
|
if (document.RootElement.TryGetProperty("Exeption", out var exeptionElement))
|
||||||
|
{
|
||||||
|
throw new RemoteException(exeptionElement.GetString()) { CallRequestId = requestId };
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsed = document.Deserialize<FinalCommandExecution<T>>();
|
||||||
while (parsed.CallRequestId != requestId)
|
while (parsed.CallRequestId != requestId)
|
||||||
{
|
{
|
||||||
receiveMessage = await _interactionModule.ReceiveMessage();
|
receiveMessage = await _interactionModule.ReceiveMessage();
|
||||||
@@ -52,3 +58,9 @@ public class JsonFrontendSerialisationModule
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RemoteException(string error) : Exception
|
||||||
|
{
|
||||||
|
public Guid CallRequestId;
|
||||||
|
public override string Message => error;
|
||||||
|
}
|
||||||
@@ -5,12 +5,12 @@
|
|||||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mikhail\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Mimm\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<SourceRoot Include="C:\Users\Mikhail\.nuget\packages\" />
|
<SourceRoot Include="C:\Users\Mimm\.nuget\packages\" />
|
||||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user