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