From 932f915f28136b32af0ebaafa8486cbcad378ef3 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Wed, 12 Feb 2025 23:01:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=84=D0=B8=D1=86=D0=B8=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7?= =?UTF-8?q?=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D1=8F=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=D0=BE=D0=B2=20=D0=B8=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=20=D0=B1=D0=B5=D0=BD=D1=87=D0=BC=D0=B0=D1=80?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mROA.Benchmark/Program.cs | 9 +++ mROA.Benchmark/mROA.Benchmark.csproj | 10 ++++ mROA.sln | 6 ++ .../Implementation/RemoteContextRepository.cs | 55 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 mROA.Benchmark/Program.cs create mode 100644 mROA.Benchmark/mROA.Benchmark.csproj create mode 100644 mROA/Implementation/RemoteContextRepository.cs diff --git a/mROA.Benchmark/Program.cs b/mROA.Benchmark/Program.cs new file mode 100644 index 0000000..24fe190 --- /dev/null +++ b/mROA.Benchmark/Program.cs @@ -0,0 +1,9 @@ +namespace mROA.Benchmark; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + } +} \ No newline at end of file diff --git a/mROA.Benchmark/mROA.Benchmark.csproj b/mROA.Benchmark/mROA.Benchmark.csproj new file mode 100644 index 0000000..85b4959 --- /dev/null +++ b/mROA.Benchmark/mROA.Benchmark.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/mROA.sln b/mROA.sln index 41c3836..7586eb3 100644 --- a/mROA.sln +++ b/mROA.sln @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Shared", "Example.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Frontend", "Example.Frontend\Example.Frontend.csproj", "{9BD25A13-3165-47C0-9EAA-5C59EC490E32}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Benchmark", "mROA.Benchmark\mROA.Benchmark.csproj", "{6868F42B-E30D-4040-AD4A-BC2A2E76D03A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -47,6 +49,10 @@ Global {9BD25A13-3165-47C0-9EAA-5C59EC490E32}.Debug|Any CPU.Build.0 = Debug|Any CPU {9BD25A13-3165-47C0-9EAA-5C59EC490E32}.Release|Any CPU.ActiveCfg = Release|Any CPU {9BD25A13-3165-47C0-9EAA-5C59EC490E32}.Release|Any CPU.Build.0 = Release|Any CPU + {6868F42B-E30D-4040-AD4A-BC2A2E76D03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6868F42B-E30D-4040-AD4A-BC2A2E76D03A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6868F42B-E30D-4040-AD4A-BC2A2E76D03A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6868F42B-E30D-4040-AD4A-BC2A2E76D03A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mROA/Implementation/RemoteContextRepository.cs b/mROA/Implementation/RemoteContextRepository.cs new file mode 100644 index 0000000..e29672e --- /dev/null +++ b/mROA/Implementation/RemoteContextRepository.cs @@ -0,0 +1,55 @@ +using System.Collections.Frozen; +using System.Collections.Immutable; +using mROA.Abstract; + +namespace mROA.Implementation; + +public class RemoteContextRepository : IContextRepository +{ + private ISerialisationModule.IFrontendSerialisationModule _serialisationModule; + public static FrozenDictionary RemoteTypes; + public int ResisterObject(object o) + { + throw new NotSupportedException(); + } + + public void ClearObject(int id) + { + throw new NotSupportedException(); + } + + public object GetObject(int id) + { + throw new NotSupportedException(); + } + + public T GetObject(int id) + { + if (RemoteTypes.TryGetValue(typeof(T), out var remoteType)) + { + var remote = (T)Activator.CreateInstance(remoteType, id, _serialisationModule)!; + return remote; + } + throw new NotSupportedException(); + } + + public object GetSingleObject(Type type) + { + return Activator.CreateInstance(RemoteTypes[type], -1, _serialisationModule)!; + } + + public int GetObjectIndex(object o) + { + if (o is IRemoteObject remote) + { + return remote.Id; + } + throw new NotSupportedException(); + } + + public void Inject(T dependency) + { + if (dependency is ISerialisationModule.IFrontendSerialisationModule serialisationModule) + _serialisationModule = serialisationModule; + } +} \ No newline at end of file