начало кодгена
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
[SharedObjectInterafce]
|
||||
public interface ITestController
|
||||
{
|
||||
void A();
|
||||
Task AAsync(CancellationToken cancellationToken);
|
||||
int B();
|
||||
Task<int> BAsync(CancellationToken cancellationToken);
|
||||
TransmittedSharedObject<ITestController> SharedObjectTransmitionTest();
|
||||
int Parametrized(TestParameter parameter);
|
||||
TransmittedSharedObject<ITestParameter> GetTestParameter();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
[SharedObjectInterafce]
|
||||
public interface ITestParameter
|
||||
{
|
||||
public int Test();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace mROA.Example;
|
||||
|
||||
public class MainX
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
[SharedObjectSingleton]
|
||||
public class TestController : ITestController
|
||||
{
|
||||
public ITestController? ReturnIfNotNull;
|
||||
private int _bOut = 5;
|
||||
|
||||
public void A()
|
||||
{
|
||||
Console.WriteLine("A called");
|
||||
}
|
||||
|
||||
public Task AAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public int B()
|
||||
{
|
||||
return _bOut++;
|
||||
}
|
||||
|
||||
public Task<int> BAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(5);
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
|
||||
{
|
||||
return new TransmissionTestController { ReturnIfNotNull = ReturnIfNotNull ?? new TestController() };
|
||||
}
|
||||
|
||||
public int Parametrized(TestParameter parameter)
|
||||
{
|
||||
return parameter.A + parameter.LinkedObject.Value.Test();
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestParameter> GetTestParameter()
|
||||
{
|
||||
return new TestParameterInstance();
|
||||
}
|
||||
}
|
||||
@@ -1,122 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Test;
|
||||
|
||||
[SharedObjectInterafce]
|
||||
public interface ITestController
|
||||
{
|
||||
void A();
|
||||
Task AAsync(CancellationToken cancellationToken);
|
||||
int B();
|
||||
Task<int> BAsync(CancellationToken cancellationToken);
|
||||
TransmittedSharedObject<ITestController> SharedObjectTransmitionTest();
|
||||
int Parametrized(TestParameter parameter);
|
||||
TransmittedSharedObject<ITestParameter> GetTestParameter();
|
||||
}
|
||||
|
||||
[SharedObjectSingleton]
|
||||
public class TestController : ITestController
|
||||
{
|
||||
public ITestController? ReturnIfNotNull;
|
||||
private int _bOut = 5;
|
||||
|
||||
public void A()
|
||||
{
|
||||
Console.WriteLine("A called");
|
||||
}
|
||||
|
||||
public Task AAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public int B()
|
||||
{
|
||||
return _bOut++;
|
||||
}
|
||||
|
||||
public Task<int> BAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(5);
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
|
||||
{
|
||||
return new TransmissionTestController { ReturnIfNotNull = ReturnIfNotNull ?? new TestController() };
|
||||
}
|
||||
|
||||
public int Parametrized(TestParameter parameter)
|
||||
{
|
||||
return parameter.A + parameter.LinkedObject.Value.Test();
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestParameter> GetTestParameter()
|
||||
{
|
||||
return new TestParameterInstance();
|
||||
}
|
||||
}
|
||||
|
||||
[SharedObjectInterafce]
|
||||
public interface ITestParameter
|
||||
{
|
||||
public int Test();
|
||||
}
|
||||
|
||||
public class TestParameterInstance : ITestParameter
|
||||
{
|
||||
public int Test() => 10;
|
||||
}
|
||||
|
||||
public class TransmissionTestController : ITestController
|
||||
{
|
||||
public ITestController ReturnIfNotNull;
|
||||
|
||||
public void A()
|
||||
{
|
||||
Console.WriteLine("A called alternative");
|
||||
}
|
||||
|
||||
public Task AAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public int B()
|
||||
{
|
||||
return 456789;
|
||||
}
|
||||
|
||||
public Task<int> BAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(465789);
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
|
||||
{
|
||||
TransmittedSharedObject<ITestController> x = new TestController();
|
||||
|
||||
|
||||
return new TestController { ReturnIfNotNull = this };
|
||||
}
|
||||
|
||||
public int Parametrized(TestParameter parameter)
|
||||
{
|
||||
return parameter.A * parameter.LinkedObject.Value.Test();
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestParameter> GetTestParameter()
|
||||
{
|
||||
return new TestParameterInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestParameter
|
||||
{
|
||||
public int A { get; set; }
|
||||
public TransmittedSharedObject<ITestParameter> LinkedObject { get; set; }
|
||||
}
|
||||
namespace mROA.Example;
|
||||
|
||||
public class TestControllerRemoteEndpoint(int id, ISerialisationModule.IFrontendSerialisationModule serialisationModule)
|
||||
: ITestController, IRemoteObject
|
||||
@@ -196,21 +81,5 @@ public class TestControllerRemoteEndpoint(int id, ISerialisationModule.IFrontend
|
||||
return convertation;
|
||||
}
|
||||
|
||||
public int Id => id;
|
||||
}
|
||||
|
||||
public class TestParameterRemoteEndpoint(int id, ISerialisationModule.IFrontendSerialisationModule serialisationModule) : ITestParameter, IRemoteObject{
|
||||
public int Test()
|
||||
{
|
||||
var request = new JsonCallRequest { CommandId = 7, ObjectId = id };
|
||||
serialisationModule.PostCallRequest(request);
|
||||
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
|
||||
.GetAwaiter().GetResult();
|
||||
TransmissionConfig.SetupFrontendRepository();
|
||||
var convertation = response.Result! is JsonElement e ? e.Deserialize<int>() : (int)response.Result!;
|
||||
TransmissionConfig.SetupBackendRepository();
|
||||
return convertation;
|
||||
}
|
||||
|
||||
public int Id => id;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
public class TestParameter
|
||||
{
|
||||
public int A { get; set; }
|
||||
public TransmittedSharedObject<ITestParameter> LinkedObject { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace mROA.Example;
|
||||
|
||||
public class TestParameterInstance : ITestParameter
|
||||
{
|
||||
public int Test() => 10;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json;
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
public class TestParameterRemoteEndpoint(int id, ISerialisationModule.IFrontendSerialisationModule serialisationModule) : ITestParameter, IRemoteObject{
|
||||
public int Test()
|
||||
{
|
||||
var request = new JsonCallRequest { CommandId = 7, ObjectId = id };
|
||||
serialisationModule.PostCallRequest(request);
|
||||
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
|
||||
.GetAwaiter().GetResult();
|
||||
TransmissionConfig.SetupFrontendRepository();
|
||||
var convertation = response.Result! is JsonElement e ? e.Deserialize<int>() : (int)response.Result!;
|
||||
TransmissionConfig.SetupBackendRepository();
|
||||
return convertation;
|
||||
}
|
||||
|
||||
public int Id => id;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Example;
|
||||
|
||||
public class TransmissionTestController : ITestController
|
||||
{
|
||||
public ITestController ReturnIfNotNull;
|
||||
|
||||
public void A()
|
||||
{
|
||||
Console.WriteLine("A called alternative");
|
||||
}
|
||||
|
||||
public Task AAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public int B()
|
||||
{
|
||||
return 456789;
|
||||
}
|
||||
|
||||
public Task<int> BAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(465789);
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
|
||||
{
|
||||
TransmittedSharedObject<ITestController> x = new TestController();
|
||||
|
||||
|
||||
return new TestController { ReturnIfNotNull = this };
|
||||
}
|
||||
|
||||
public int Parametrized(TestParameter parameter)
|
||||
{
|
||||
return parameter.A * parameter.LinkedObject.Value.Test();
|
||||
}
|
||||
|
||||
public TransmittedSharedObject<ITestParameter> GetTestParameter()
|
||||
{
|
||||
return new TestParameterInstance();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using mROA.Example;
|
||||
using mROA.Implementation;
|
||||
|
||||
namespace mROA.Test;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using mROA.Example;
|
||||
using mROA.Implementation;
|
||||
using Newtonsoft.Json;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\mROA.Example\mROA.Example.csproj" />
|
||||
<ProjectReference Include="..\mROA\mROA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA", "mROA\mROA.csproj",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Test", "mROA.Test\mROA.Test.csproj", "{D0E5760B-BB6E-453A-B396-A972CD94F133}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Codegen", "mROA.Codegen\mROA.Codegen.csproj", "{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Example", "mROA.Example\mROA.Example.csproj", "{5F4EEF2B-A82C-44DA-8995-AF1668A238EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -18,5 +22,13 @@ Global
|
||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5F4EEF2B-A82C-44DA-8995-AF1668A238EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5F4EEF2B-A82C-44DA-8995-AF1668A238EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5F4EEF2B-A82C-44DA-8995-AF1668A238EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5F4EEF2B-A82C-44DA-8995-AF1668A238EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -10,6 +10,8 @@ public interface ISerialisationModule
|
||||
public interface IFrontendSerialisationModule
|
||||
{
|
||||
Task<T> GetNextCommandExecution<T>(Guid requestId) where T : ICommandExecution;
|
||||
Task<FinalCommandExecution> GetFinalCommandExecution<T>(Guid requestId);
|
||||
|
||||
void PostCallRequest(ICallRequest callRequest);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,19 @@ public class JsonFrontendSerialisationModule(IInteractionModule.IFrontendInterac
|
||||
return parsed;
|
||||
}
|
||||
|
||||
public async Task<FinalCommandExecution> GetFinalCommandExecution<T>(Guid requestId)
|
||||
{
|
||||
var receiveMessage = await interactionModule.ReceiveMessage();
|
||||
var parsed = JsonSerializer.Deserialize<FinalCommandExecution>(receiveMessage);
|
||||
while (parsed.CallRequestId != requestId)
|
||||
{
|
||||
receiveMessage = await interactionModule.ReceiveMessage();
|
||||
parsed = JsonSerializer.Deserialize<FinalCommandExecution>(receiveMessage);
|
||||
}
|
||||
parsed.Result = parsed.Result! is JsonElement e ? e.Deserialize<T>() : (T)parsed.Result!;
|
||||
return parsed;
|
||||
}
|
||||
|
||||
public void PostCallRequest(ICallRequest callRequest)
|
||||
{
|
||||
var post = JsonSerializer.Serialize(callRequest, callRequest.GetType());
|
||||
|
||||
Reference in New Issue
Block a user