контекстный вызов работает и передача объектов по сети тоже
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <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>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Performance")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Performance")]
|
||||||
[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+da60eb27f99600ee3a9ee8526d2b26260efd8225")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2f1a1e250b1a9c031df21e3ec1087cb18b8fa784")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Performance")]
|
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Performance")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Performance")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Performance")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -5,15 +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.10.1</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>
|
||||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
|
||||||
<PkgNUnit_Analyzers Condition=" '$(PkgNUnit_Analyzers)' == '' ">C:\Users\Mikhail\.nuget\packages\nunit.analyzers\4.3.0</PkgNUnit_Analyzers>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -9,12 +9,16 @@ public interface ITestController
|
|||||||
Task AAsync(CancellationToken cancellationToken);
|
Task AAsync(CancellationToken cancellationToken);
|
||||||
int B();
|
int B();
|
||||||
Task<int> BAsync(CancellationToken cancellationToken);
|
Task<int> BAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
TransmittedSharedObject<ITestController> SharedObjectTransmitionTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SharedObjectSingleton]
|
[SharedObjectSingleton]
|
||||||
public class TestController : ITestController
|
public class TestController : ITestController
|
||||||
{
|
{
|
||||||
|
public ITestController? ReturnIfNotNull;
|
||||||
private int _bOut = 5;
|
private int _bOut = 5;
|
||||||
|
|
||||||
public void A()
|
public void A()
|
||||||
{
|
{
|
||||||
Console.WriteLine("A called");
|
Console.WriteLine("A called");
|
||||||
@@ -34,4 +38,40 @@ public class TestController : ITestController
|
|||||||
{
|
{
|
||||||
return Task.FromResult(5);
|
return Task.FromResult(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
|
||||||
|
{
|
||||||
|
return new TransmittionTestController { ReturnIfNotNull = ReturnIfNotNull ?? new TestController() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TransmittionTestController : 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()
|
||||||
|
{
|
||||||
|
return new TestController { ReturnIfNotNull = this };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+48
-4
@@ -1,6 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.Json;
|
||||||
using mROA.Implementation;
|
using mROA.Implementation;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace mROA.Test;
|
namespace mROA.Test;
|
||||||
|
|
||||||
@@ -27,7 +30,7 @@ public class Tests
|
|||||||
_contextRepository = repo2;
|
_contextRepository = repo2;
|
||||||
|
|
||||||
_executeModule = new PrepairedExecutionModule(_methodRepository, _serialisationModule, _contextRepository);
|
_executeModule = new PrepairedExecutionModule(_methodRepository, _serialisationModule, _contextRepository);
|
||||||
|
TransmissionConfig.DefaultContextRepository = _contextRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -41,7 +44,7 @@ public class Tests
|
|||||||
"CommandId": 2
|
"CommandId": 2
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
Assert.Pass(sw.ElapsedMilliseconds.ToString());
|
Assert.Pass(_interactionModule.OutputBuffer.Last());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -56,7 +59,7 @@ public class Tests
|
|||||||
""");
|
""");
|
||||||
while (_interactionModule.OutputBuffer.Count != 2) ;
|
while (_interactionModule.OutputBuffer.Count != 2) ;
|
||||||
|
|
||||||
Assert.Pass(sw.ElapsedMilliseconds.ToString());
|
Assert.Pass(_interactionModule.OutputBuffer.Last());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -64,7 +67,7 @@ public class Tests
|
|||||||
{
|
{
|
||||||
var repo = new MethodRepository();
|
var repo = new MethodRepository();
|
||||||
repo.CollectForAssembly(Assembly.GetExecutingAssembly());
|
repo.CollectForAssembly(Assembly.GetExecutingAssembly());
|
||||||
Assert.That(repo.GetMethods().ToList().Count == 4);
|
Assert.That(repo.GetMethods().ToList().Count == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -76,4 +79,45 @@ public class Tests
|
|||||||
singleObject.B();
|
singleObject.B();
|
||||||
Assert.That(singleObject.B() == 6);
|
Assert.That(singleObject.B() == 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TransmissionTest()
|
||||||
|
{
|
||||||
|
_interactionModule.PassCommand(132, """
|
||||||
|
{
|
||||||
|
"CommandId": 4
|
||||||
|
}
|
||||||
|
""");
|
||||||
|
var response =
|
||||||
|
JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
|
||||||
|
JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
|
||||||
|
?.Result.ToString()
|
||||||
|
);
|
||||||
|
|
||||||
|
_interactionModule.PassCommand(132,
|
||||||
|
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||||
|
|
||||||
|
var firstFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
|
||||||
|
.GetInt32();
|
||||||
|
|
||||||
|
_interactionModule.PassCommand(132,
|
||||||
|
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 4, ObjectId = response.ContextId }));
|
||||||
|
|
||||||
|
response =
|
||||||
|
JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
|
||||||
|
JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
|
||||||
|
?.Result.ToString()
|
||||||
|
);
|
||||||
|
|
||||||
|
_interactionModule.PassCommand(132,
|
||||||
|
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||||
|
_interactionModule.PassCommand(132,
|
||||||
|
JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }));
|
||||||
|
|
||||||
|
var secondFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
|
||||||
|
.GetInt32();
|
||||||
|
|
||||||
|
Assert.That(firstFull == 456789 && secondFull == 6);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,15 +9,21 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
|
<PackageReference Include="coverlet.collector" Version="6.0.3">
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<PackageReference Include="NUnit" Version="4.2.2"/>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"/>
|
</PackageReference>
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||||
|
<PackageReference Include="NUnit" Version="4.3.2" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="4.6.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="NUnit.Framework"/>
|
<Using Include="NUnit.Framework" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <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>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -13,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+da60eb27f99600ee3a9ee8526d2b26260efd8225")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2f1a1e250b1a9c031df21e3ec1087cb18b8fa784")]
|
||||||
[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")]
|
||||||
|
|||||||
@@ -5,22 +5,22 @@
|
|||||||
<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.10.1</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)nunit3testadapter\4.6.0\build\netcoreapp3.1\NUnit3TestAdapter.props" Condition="Exists('$(NuGetPackageRoot)nunit3testadapter\4.6.0\build\netcoreapp3.1\NUnit3TestAdapter.props')" />
|
<Import Project="$(NuGetPackageRoot)nunit3testadapter\4.6.0\build\netcoreapp3.1\NUnit3TestAdapter.props" Condition="Exists('$(NuGetPackageRoot)nunit3testadapter\4.6.0\build\netcoreapp3.1\NUnit3TestAdapter.props')" />
|
||||||
<Import Project="$(NuGetPackageRoot)nunit\4.2.2\build\NUnit.props" Condition="Exists('$(NuGetPackageRoot)nunit\4.2.2\build\NUnit.props')" />
|
<Import Project="$(NuGetPackageRoot)nunit\4.3.2\build\NUnit.props" Condition="Exists('$(NuGetPackageRoot)nunit\4.3.2\build\NUnit.props')" />
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.testplatform.testhost\17.11.1\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props" Condition="Exists('$(NuGetPackageRoot)microsoft.testplatform.testhost\17.11.1\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.testplatform.testhost\17.12.0\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props" Condition="Exists('$(NuGetPackageRoot)microsoft.testplatform.testhost\17.12.0\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props')" />
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.11.1\build\netstandard2.0\Microsoft.CodeCoverage.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.11.1\build\netstandard2.0\Microsoft.CodeCoverage.props')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.12.0\build\netstandard2.0\Microsoft.CodeCoverage.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.12.0\build\netstandard2.0\Microsoft.CodeCoverage.props')" />
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.11.1\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.11.1\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.3.0</PkgNUnit_Analyzers>
|
<PkgNUnit_Analyzers Condition=" '$(PkgNUnit_Analyzers)' == '' ">C:\Users\Mimm\.nuget\packages\nunit.analyzers\4.6.0</PkgNUnit_Analyzers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.11.1\build\netstandard2.0\Microsoft.CodeCoverage.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.11.1\build\netstandard2.0\Microsoft.CodeCoverage.targets')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.12.0\build\netstandard2.0\Microsoft.CodeCoverage.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.12.0\build\netstandard2.0\Microsoft.CodeCoverage.targets')" />
|
||||||
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.11.1\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.11.1\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets')" />
|
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.12.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets')" />
|
||||||
<Import Project="$(NuGetPackageRoot)coverlet.collector\6.0.2\build\netstandard2.0\coverlet.collector.targets" Condition="Exists('$(NuGetPackageRoot)coverlet.collector\6.0.2\build\netstandard2.0\coverlet.collector.targets')" />
|
<Import Project="$(NuGetPackageRoot)coverlet.collector\6.0.3\build\netstandard2.0\coverlet.collector.targets" Condition="Exists('$(NuGetPackageRoot)coverlet.collector\6.0.3\build\netstandard2.0\coverlet.collector.targets')" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -6,4 +6,5 @@ public interface IContextRepository
|
|||||||
void ClearObject(int id);
|
void ClearObject(int id);
|
||||||
object GetObject(int id);
|
object GetObject(int id);
|
||||||
object GetSingleObject(Type type);
|
object GetSingleObject(Type type);
|
||||||
|
int GetObjectIndex(object o);
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,8 @@ public class ContextRepository : IContextRepository
|
|||||||
{
|
{
|
||||||
private FrozenDictionary<int, object?> _singletons;
|
private FrozenDictionary<int, object?> _singletons;
|
||||||
private object[] _storage;
|
private object[] _storage;
|
||||||
private int _lastIndex;
|
|
||||||
|
|
||||||
private Task<int>? _lastIndexFinder;
|
private Task<int>? _lastIndexFinder = Task.FromResult(0);
|
||||||
|
|
||||||
const int StartupSize = 1024;
|
const int StartupSize = 1024;
|
||||||
const int GrowSize = 128;
|
const int GrowSize = 128;
|
||||||
@@ -33,14 +32,12 @@ public class ContextRepository : IContextRepository
|
|||||||
if (_lastIndexFinder is not null)
|
if (_lastIndexFinder is not null)
|
||||||
_lastIndexFinder.Wait();
|
_lastIndexFinder.Wait();
|
||||||
|
|
||||||
var oldIndex = _lastIndex;
|
_storage[_lastIndexFinder.Result] = o;
|
||||||
_lastIndex = _lastIndexFinder.Result;
|
|
||||||
|
|
||||||
_storage[oldIndex] = o;
|
|
||||||
|
|
||||||
|
var last = _lastIndexFinder.Result;
|
||||||
_lastIndexFinder = FindLastIndex();
|
_lastIndexFinder = FindLastIndex();
|
||||||
|
|
||||||
return _lastIndex;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearObject(int id)
|
public void ClearObject(int id)
|
||||||
@@ -59,6 +56,14 @@ public class ContextRepository : IContextRepository
|
|||||||
return _singletons.TryGetValue(type.GetHashCode(), out var value) ? value : null;
|
return _singletons.TryGetValue(type.GetHashCode(), out var value) ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetObjectIndex(object o)
|
||||||
|
{
|
||||||
|
var index = Array.IndexOf(_storage, o);
|
||||||
|
if (index == -1)
|
||||||
|
return ResisterObject(o);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<int> FindLastIndex()
|
private async Task<int> FindLastIndex()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _storage.Length; i++)
|
for (int i = 0; i < _storage.Length; i++)
|
||||||
|
|||||||
@@ -18,13 +18,9 @@ public class JsonSerialisationModule : ISerialisationModule
|
|||||||
|
|
||||||
public void HandleIncomingRequest(int clientId, string command)
|
public void HandleIncomingRequest(int clientId, string command)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
JsonCallRequest request = JsonSerializer.Deserialize<JsonCallRequest>(command);
|
JsonCallRequest request = JsonSerializer.Deserialize<JsonCallRequest>(command);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
request.ClientId = clientId;
|
request.ClientId = clientId;
|
||||||
|
|
||||||
var response = _executeModule.Execute(request);
|
var response = _executeModule.Execute(request);
|
||||||
PostResponse(response);
|
PostResponse(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace mROA.Implementation;
|
||||||
|
|
||||||
|
public static class TransmissionConfig
|
||||||
|
{
|
||||||
|
public static IContextRepository DefaultContextRepository { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TransmittedSharedObject<T>
|
||||||
|
{
|
||||||
|
public int ContextId { get; set; } = -1;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public T Value { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public IContextRepository Context { get; set; }
|
||||||
|
|
||||||
|
public static implicit operator T(TransmittedSharedObject<T> value) => value.Value;
|
||||||
|
|
||||||
|
public static implicit operator TransmittedSharedObject<T>(T value) =>
|
||||||
|
new() { Value = value, ContextId = TransmissionConfig.DefaultContextRepository.GetObjectIndex(value) };
|
||||||
|
|
||||||
|
// public void Fill() => Value = (T)TransmissionConfig.DefaultContextRepository.GetObject(ContextId);
|
||||||
|
// public void Collect() => ContextId = TransmissionConfig.DefaultContextRepository.GetObjectIndex(ContextId);
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA")]
|
||||||
[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+da60eb27f99600ee3a9ee8526d2b26260efd8225")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2f1a1e250b1a9c031df21e3ec1087cb18b8fa784")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("mROA")]
|
[assembly: System.Reflection.AssemblyProductAttribute("mROA")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("mROA")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("mROA")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.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.10.1</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