diff --git a/Example.Backend/Example.Backend.csproj b/Example.Backend/Example.Backend.csproj
index 95845de..2306674 100644
--- a/Example.Backend/Example.Backend.csproj
+++ b/Example.Backend/Example.Backend.csproj
@@ -22,4 +22,8 @@
+
+
+
+
diff --git a/Example.Backend/Program.cs b/Example.Backend/Program.cs
index 52016a0..b24e1ff 100644
--- a/Example.Backend/Program.cs
+++ b/Example.Backend/Program.cs
@@ -8,53 +8,61 @@ using mROA.Cbor;
using mROA.Codegen;
using mROA.Implementation;
using mROA.Implementation.Backend;
-using mROA.Implementation.Bootstrap;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
class Program
{
public static void Main(string[] args)
{
- var builder = new FullMixBuilder();
- // builder.UseJsonSerialisation();
- builder.Modules.Add(new CborSerializationToolkit());
- builder.Modules.Add(new BackendIdentityGenerator());
- // builder.UseNetworkGateway(new IPEndPoint(IPAddress.Loopback, 4567), typeof(NextGenerationInteractionModule),
- // builder.GetModule()!);
+ var builder = Host.CreateApplicationBuilder();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddOptions();
var listening = new IPEndPoint(IPAddress.Any, 4567);
- builder.UseNetworkGateway(listening, typeof(ChannelInteractionModule),
- builder.GetModule()!);
- builder.Modules.Add(new UdpGateway(listening));
- builder.Modules.Add(new ConnectionHub());
- builder.Modules.Add(new HubRequestExtractor());
- builder.UseBasicExecution();
- builder.Modules.Add(new CreativeRepresentationModuleProducer(
- new IInjectableModule[] { builder.GetModule()! },
- typeof(RepresentationModule)));
- builder.Modules.Add(new RemoteInstanceRepository());
-// builder.UseCollectableContextRepository(typeof(PrinterFactory).Assembly);
- builder.Modules.Add(new MultiClientInstanceRepository(i =>
+ builder.Services.Configure(options => options.Endpoint = listening);
+
+ builder.Services.AddSingleton();
+
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton(provider => new MultiClientInstanceRepository(i =>
{
- var repo = new InstanceRepository();
+ var producer = provider.GetService();
+ var repo = new InstanceRepository(producer);
repo.FillSingletons(typeof(PrinterFactory).Assembly);
- repo.Inject(builder.Modules.OfType().First());
+
return repo;
}));
- var methodRepo = new CollectableMethodRepository();
- methodRepo.AppendInvokers(new GeneratedInvokersCollection());
- builder.Modules.Add(methodRepo);
- builder.Modules.Add(new GeneratedCallIndexProvider());
- builder.Modules.Add(new GeneratedCallIndexProvider());
- builder.Modules.Add(new CancellationRepository());
- builder.Build();
- new RemoteTypeBinder();
+ builder.Services.AddSingleton(p =>
+ {
+ var methodRepo = new CollectableMethodRepository();
+ methodRepo.AppendInvokers(new GeneratedInvokersCollection());
+ return methodRepo;
+ });
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+
+ var mroaMachine = builder.Build();
+
+ mroaMachine.StartAsync();
+//
+// builder.Build();
+// new RemoteTypeBinder();
+//
+//
+ _ = mroaMachine.Services.GetService()!.Start();
+ var gateway = mroaMachine.Services.GetService();
+ gateway.Run();
+
+ Console.ReadLine();
- _ = builder.GetModule()!.Start();
- var gateway = builder.GetModule();
- gateway.Run();
-
- Console.ReadLine();
}
}
\ No newline at end of file
diff --git a/Example.Frontend/Example.Frontend.csproj b/Example.Frontend/Example.Frontend.csproj
index fdac1b1..9deed54 100644
--- a/Example.Frontend/Example.Frontend.csproj
+++ b/Example.Frontend/Example.Frontend.csproj
@@ -21,4 +21,8 @@
+
+
+
+
diff --git a/Example.Load/Example.Load.csproj b/Example.Load/Example.Load.csproj
index affee32..71a5437 100644
--- a/Example.Load/Example.Load.csproj
+++ b/Example.Load/Example.Load.csproj
@@ -13,4 +13,8 @@
+
+
+
+
diff --git a/Example.Shared/Example.Shared.csproj b/Example.Shared/Example.Shared.csproj
index f727333..2cb81ef 100644
--- a/Example.Shared/Example.Shared.csproj
+++ b/Example.Shared/Example.Shared.csproj
@@ -14,6 +14,7 @@
+
diff --git a/mROA.Cbor/IOrdinaryStructureParser.cs b/mROA.Cbor/IOrdinaryStructureParser.cs
index 56c1c4a..8faa205 100644
--- a/mROA.Cbor/IOrdinaryStructureParser.cs
+++ b/mROA.Cbor/IOrdinaryStructureParser.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Formats.Cbor;
using mROA.Abstract;
using mROA.Implementation;
diff --git a/mROA/Abstract/ICallIndexProvider.cs b/mROA/Abstract/ICallIndexProvider.cs
index 7dc2b7d..3169e68 100644
--- a/mROA/Abstract/ICallIndexProvider.cs
+++ b/mROA/Abstract/ICallIndexProvider.cs
@@ -5,7 +5,7 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface ICallIndexProvider : IInjectableModule
+ public interface ICallIndexProvider
{
Dictionary> Activators
{
diff --git a/mROA/Abstract/ICancellationRepository.cs b/mROA/Abstract/ICancellationRepository.cs
index 489a648..22189cb 100644
--- a/mROA/Abstract/ICancellationRepository.cs
+++ b/mROA/Abstract/ICancellationRepository.cs
@@ -3,7 +3,7 @@ using System.Threading;
namespace mROA.Abstract
{
- public interface ICancellationRepository : IInjectableModule
+ public interface ICancellationRepository
{
void RegisterCancellation(Guid id, CancellationTokenSource cts);
CancellationTokenSource? GetCancellation(Guid id);
diff --git a/mROA/Abstract/IChannelInteractionModule.cs b/mROA/Abstract/IChannelInteractionModule.cs
index 9b56492..2358d3d 100644
--- a/mROA/Abstract/IChannelInteractionModule.cs
+++ b/mROA/Abstract/IChannelInteractionModule.cs
@@ -5,10 +5,10 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface IChannelInteractionModule : IInjectableModule, IDisposable
+ public interface IChannelInteractionModule : IDisposable
{
int ConnectionId { get; set; }
- IEndPointContext Context { get; }
+ IEndPointContext Context { get; set; }
Channel ReceiveChanel { get; }
ChannelReader TrustedPostChanel { get; }
ChannelReader UntrustedPostChanel { get; }
diff --git a/mROA/Abstract/IConnectionHub.cs b/mROA/Abstract/IConnectionHub.cs
index 01f60b9..2b5e6c6 100644
--- a/mROA/Abstract/IConnectionHub.cs
+++ b/mROA/Abstract/IConnectionHub.cs
@@ -4,7 +4,7 @@
public delegate void DisconnectionHandler(IRepresentationModule representationModule);
- public interface IConnectionHub : IInjectableModule
+ public interface IConnectionHub
{
void RegisterInteraction(IChannelInteractionModule interaction);
IChannelInteractionModule GetInteraction(int id);
diff --git a/mROA/Abstract/IContextualSerializationToolKit.cs b/mROA/Abstract/IContextualSerializationToolKit.cs
index ca6f5a0..906657b 100644
--- a/mROA/Abstract/IContextualSerializationToolKit.cs
+++ b/mROA/Abstract/IContextualSerializationToolKit.cs
@@ -2,7 +2,7 @@
namespace mROA.Abstract
{
- public interface IContextualSerializationToolKit : IInjectableModule
+ public interface IContextualSerializationToolKit
{
byte[] Serialize(object objectToSerialize, IEndPointContext? context);
int Serialize(object objectToSerialize, Span destination, IEndPointContext? context);
diff --git a/mROA/Abstract/IEndPointContext.cs b/mROA/Abstract/IEndPointContext.cs
index 2e885f6..f7aa076 100644
--- a/mROA/Abstract/IEndPointContext.cs
+++ b/mROA/Abstract/IEndPointContext.cs
@@ -1,6 +1,6 @@
namespace mROA.Abstract
{
- public interface IEndPointContext : IInjectableModule
+ public interface IEndPointContext
{
IInstanceRepository RealRepository { get; set; }
IInstanceRepository RemoteRepository { get; set; }
diff --git a/mROA/Abstract/IExecuteModule.cs b/mROA/Abstract/IExecuteModule.cs
index ea87f0d..c45a378 100644
--- a/mROA/Abstract/IExecuteModule.cs
+++ b/mROA/Abstract/IExecuteModule.cs
@@ -2,7 +2,7 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface IExecuteModule : IInjectableModule
+ public interface IExecuteModule
{
ICommandExecution Execute(ICallRequest command, IInstanceRepository instanceRepository,
IRepresentationModule representationModule, IEndPointContext context);
diff --git a/mROA/Abstract/IFrontendBridge.cs b/mROA/Abstract/IFrontendBridge.cs
index 7ce7460..8c0969e 100644
--- a/mROA/Abstract/IFrontendBridge.cs
+++ b/mROA/Abstract/IFrontendBridge.cs
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
namespace mROA.Abstract
{
- public interface IFrontendBridge : IInjectableModule, IDisposable
+ public interface IFrontendBridge : IDisposable
{
Task Connect();
void Obstacle();
diff --git a/mROA/Abstract/IGatewayModule.cs b/mROA/Abstract/IGatewayModule.cs
index 77c869f..cfa25d1 100644
--- a/mROA/Abstract/IGatewayModule.cs
+++ b/mROA/Abstract/IGatewayModule.cs
@@ -2,7 +2,7 @@ using System;
namespace mROA.Abstract
{
- public interface IGatewayModule : IDisposable, IInjectableModule
+ public interface IGatewayModule : IDisposable
{
void Run();
}
diff --git a/mROA/Abstract/IIdentityGenerator.cs b/mROA/Abstract/IIdentityGenerator.cs
index 6123cdd..34fd1cb 100644
--- a/mROA/Abstract/IIdentityGenerator.cs
+++ b/mROA/Abstract/IIdentityGenerator.cs
@@ -1,6 +1,6 @@
namespace mROA.Abstract
{
- public interface IIdentityGenerator : IInjectableModule
+ public interface IIdentityGenerator
{
int GetNextIdentity();
}
diff --git a/mROA/Abstract/IInjectableModule.cs b/mROA/Abstract/IInjectableModule.cs
deleted file mode 100644
index 055a1a2..0000000
--- a/mROA/Abstract/IInjectableModule.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace mROA.Abstract
-{
- public interface IInjectableModule
- {
- void Inject(object dependency);
- }
-}
\ No newline at end of file
diff --git a/mROA/Abstract/IInstanceRepository.cs b/mROA/Abstract/IInstanceRepository.cs
index 7c48159..a93570c 100644
--- a/mROA/Abstract/IInstanceRepository.cs
+++ b/mROA/Abstract/IInstanceRepository.cs
@@ -3,7 +3,7 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface IInstanceRepository : IInjectableModule
+ public interface IInstanceRepository
{
int ResisterObject(object o, IEndPointContext context);
void ClearObject(ComplexObjectIdentifier id, IEndPointContext context);
diff --git a/mROA/Abstract/IMethodRepository.cs b/mROA/Abstract/IMethodRepository.cs
index 4c468f1..327a8b1 100644
--- a/mROA/Abstract/IMethodRepository.cs
+++ b/mROA/Abstract/IMethodRepository.cs
@@ -1,6 +1,6 @@
namespace mROA.Abstract
{
- public interface IMethodRepository : IInjectableModule
+ public interface IMethodRepository
{
IMethodInvoker GetMethod(int id);
}
diff --git a/mROA/Abstract/IRealStoreInstanceRepository.cs b/mROA/Abstract/IRealStoreInstanceRepository.cs
new file mode 100644
index 0000000..b740cfa
--- /dev/null
+++ b/mROA/Abstract/IRealStoreInstanceRepository.cs
@@ -0,0 +1,7 @@
+namespace mROA.Abstract
+{
+ public interface IRealStoreInstanceRepository : IInstanceRepository
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/mROA/Abstract/IRemoteObjectFactory.cs b/mROA/Abstract/IRemoteObjectFactory.cs
index 1ae127f..ac17640 100644
--- a/mROA/Abstract/IRemoteObjectFactory.cs
+++ b/mROA/Abstract/IRemoteObjectFactory.cs
@@ -2,7 +2,7 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface IRemoteObjectFactory : IInjectableModule
+ public interface IRemoteObjectFactory
{
T Produce(ComplexObjectIdentifier id, IEndPointContext context);
}
diff --git a/mROA/Abstract/IRepresentationModule.cs b/mROA/Abstract/IRepresentationModule.cs
index de90b69..7fd4bf5 100644
--- a/mROA/Abstract/IRepresentationModule.cs
+++ b/mROA/Abstract/IRepresentationModule.cs
@@ -6,7 +6,7 @@ using mROA.Implementation;
namespace mROA.Abstract
{
- public interface IRepresentationModule : IInjectableModule
+ public interface IRepresentationModule
{
int Id { get; }
IEndPointContext Context { get; }
diff --git a/mROA/Abstract/IRepresentationModuleProducer.cs b/mROA/Abstract/IRepresentationModuleProducer.cs
index 6406c78..677f442 100644
--- a/mROA/Abstract/IRepresentationModuleProducer.cs
+++ b/mROA/Abstract/IRepresentationModuleProducer.cs
@@ -1,6 +1,6 @@
namespace mROA.Abstract
{
- public interface IRepresentationModuleProducer : IInjectableModule
+ public interface IRepresentationModuleProducer
{
IRepresentationModule Produce(int id);
}
diff --git a/mROA/Abstract/IRequestExtractor.cs b/mROA/Abstract/IRequestExtractor.cs
index d49194b..f64e8a7 100644
--- a/mROA/Abstract/IRequestExtractor.cs
+++ b/mROA/Abstract/IRequestExtractor.cs
@@ -2,7 +2,7 @@ using System.Threading.Tasks;
namespace mROA.Abstract
{
- public interface IRequestExtractor : IInjectableModule
+ public interface IRequestExtractor
{
Task StartExtraction();
}
diff --git a/mROA/Abstract/IUntrustedGateway.cs b/mROA/Abstract/IUntrustedGateway.cs
index 1c6f25c..d31bafc 100644
--- a/mROA/Abstract/IUntrustedGateway.cs
+++ b/mROA/Abstract/IUntrustedGateway.cs
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
namespace mROA.Abstract
{
- public interface IUntrustedGateway : IInjectableModule, IDisposable
+ public interface IUntrustedGateway : IDisposable
{
Task Start();
}
diff --git a/mROA/Abstract/IUntrustedInteractionModule.cs b/mROA/Abstract/IUntrustedInteractionModule.cs
index 151902b..3b12c3a 100644
--- a/mROA/Abstract/IUntrustedInteractionModule.cs
+++ b/mROA/Abstract/IUntrustedInteractionModule.cs
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace mROA.Abstract
{
- public interface IUntrustedInteractionModule : IInjectableModule, IDisposable
+ public interface IUntrustedInteractionModule : IDisposable
{
Task Start(IPEndPoint endpoint);
}
diff --git a/mROA/Implementation/Backend/BackendIdentityGenerator.cs b/mROA/Implementation/Backend/BackendIdentityGenerator.cs
index 5fe3fff..27ac4f0 100644
--- a/mROA/Implementation/Backend/BackendIdentityGenerator.cs
+++ b/mROA/Implementation/Backend/BackendIdentityGenerator.cs
@@ -10,9 +10,5 @@ namespace mROA.Implementation.Backend
{
return -++_currentId;
}
-
- public void Inject(object dependency)
- {
- }
}
}
\ No newline at end of file
diff --git a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs b/mROA/Implementation/Backend/BasicConfigurationExtensions.cs
deleted file mode 100644
index a10bdd3..0000000
--- a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Net;
-using System.Reflection;
-using mROA.Abstract;
-using mROA.Implementation.Bootstrap;
-
-namespace mROA.Implementation.Backend
-{
- public static class BasicConfigurationExtensions
- {
- public static void UseNetworkGateway(this FullMixBuilder builder, IPEndPoint endPoint,
- Type interactionModuleType, params IInjectableModule[] injectableModules)
- {
- builder.Modules.Add(new NetworkGatewayModule(endPoint, interactionModuleType, injectableModules));
- }
-
- public static void UseBasicExecution(this FullMixBuilder builder)
- {
- builder.Modules.Add(new BasicExecutionModule());
- }
-
- public static void UseCollectableContextRepository(this FullMixBuilder builder, params Assembly[] assemblies)
- {
- var repo = new InstanceRepository();
- repo.FillSingletons(assemblies);
- builder.Modules.Add(repo);
- }
-
- public static void SetupMethodsRepository(this FullMixBuilder builder, IMethodRepository methodRepository)
- {
- builder.Modules.Add(methodRepository);
- }
- }
-}
\ No newline at end of file
diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs
index 6e8bf65..31f2735 100644
--- a/mROA/Implementation/Backend/BasicExecutionModule.cs
+++ b/mROA/Implementation/Backend/BasicExecutionModule.cs
@@ -7,24 +7,15 @@ namespace mROA.Implementation.Backend
{
public class BasicExecutionModule : IExecuteModule
{
- private ICancellationRepository? _cancellationRepo;
- private IMethodRepository? _methodRepo;
- private IContextualSerializationToolKit? _serialization;
+ private readonly ICancellationRepository _cancellationRepo;
+ private readonly IMethodRepository _methodRepo;
+ private readonly IContextualSerializationToolKit _serialization;
- public void Inject(object dependency)
+ public BasicExecutionModule(ICancellationRepository cancellationRepo, IMethodRepository methodRepo, IContextualSerializationToolKit serialization)
{
- switch (dependency)
- {
- case IMethodRepository methodRepo:
- _methodRepo = methodRepo;
- break;
- case ICancellationRepository cancellationRepo:
- _cancellationRepo = cancellationRepo;
- break;
- case IContextualSerializationToolKit serializationToolkit:
- _serialization = serializationToolkit;
- break;
- }
+ _cancellationRepo = cancellationRepo;
+ _methodRepo = methodRepo;
+ _serialization = serialization;
}
public ICommandExecution Execute(ICallRequest command, IInstanceRepository instanceRepository,
@@ -38,7 +29,7 @@ namespace mROA.Implementation.Backend
return CancelExecution(command);
}
- var invoker = _methodRepo!.GetMethod(command.CommandId);
+ var invoker = _methodRepo.GetMethod(command.CommandId);
if (invoker == null)
throw new Exception($"Command {command.CommandId} not found");
@@ -60,10 +51,10 @@ namespace mROA.Implementation.Backend
{
case AsyncMethodInvoker { IsVoid: false } asyncNonVoidMethodInvoker:
return TypedExecuteAsync(asyncNonVoidMethodInvoker, context, castedParams, command,
- _cancellationRepo!,
+ _cancellationRepo,
representationModule, execContext, endPointContext);
case AsyncMethodInvoker asyncMethodInvoker:
- return ExecuteAsync(asyncMethodInvoker, context, castedParams, command, _cancellationRepo!,
+ return ExecuteAsync(asyncMethodInvoker, context, castedParams, command, _cancellationRepo,
representationModule, execContext, endPointContext);
default:
var result = Execute((invoker as MethodInvoker)!, context, castedParams!, command, execContext);
@@ -99,7 +90,7 @@ namespace mROA.Implementation.Backend
object?[] castedParams = new object[invoker.ParameterTypes.Length];
for (var i = 0; i < castedParams.Length; i++)
{
- castedParams[i] = _serialization!.Cast(command.Parameters![i], invoker.ParameterTypes[i], context);
+ castedParams[i] = _serialization.Cast(command.Parameters![i], invoker.ParameterTypes[i], context);
}
return castedParams;
@@ -119,7 +110,7 @@ namespace mROA.Implementation.Backend
private FinalCommandExecution CancelExecution(ICallRequest command)
{
- var cts = _cancellationRepo!.GetCancellation(command.Id);
+ var cts = _cancellationRepo.GetCancellation(command.Id);
if (cts == null)
throw new NullReferenceException("Can't find cancellation for this request");
cts.Cancel();
@@ -237,7 +228,7 @@ namespace mROA.Implementation.Backend
Id = command.Id,
Result = finalResult
};
- _cancellationRepo!.FreeCancelation(command.Id);
+ _cancellationRepo.FreeCancelation(command.Id);
representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution,
payload, context);
diff --git a/mROA/Implementation/Backend/ConnectionHub.cs b/mROA/Implementation/Backend/ConnectionHub.cs
index ed02c65..5034a28 100644
--- a/mROA/Implementation/Backend/ConnectionHub.cs
+++ b/mROA/Implementation/Backend/ConnectionHub.cs
@@ -7,7 +7,12 @@ namespace mROA.Implementation.Backend
public class ConnectionHub : IConnectionHub
{
private readonly Dictionary _connections = new();
- private IContextualSerializationToolKit? _serializationToolkit;
+ private IContextualSerializationToolKit _serializationToolkit;
+
+ public ConnectionHub(IContextualSerializationToolKit serializationToolkit)
+ {
+ _serializationToolkit = serializationToolkit;
+ }
public void RegisterInteraction(IChannelInteractionModule interaction)
{
@@ -15,9 +20,7 @@ namespace mROA.Implementation.Backend
throw new NullReferenceException("Serialization toolkit is null");
_connections.Add(interaction.ConnectionId, interaction);
- var module = new RepresentationModule();
- module.Inject(_serializationToolkit);
- module.Inject(interaction);
+ var module = new RepresentationModule(interaction, _serializationToolkit);
OnConnected?.Invoke(module);
}
@@ -29,11 +32,5 @@ namespace mROA.Implementation.Backend
public event ConnectionHandler? OnConnected;
public event DisconnectionHandler? OnDisconnected;
-
- public void Inject(object dependency)
- {
- if (dependency is IContextualSerializationToolKit serializationToolkit)
- _serializationToolkit = serializationToolkit;
- }
}
}
\ No newline at end of file
diff --git a/mROA/Implementation/Backend/HubRequestExtractor.cs b/mROA/Implementation/Backend/HubRequestExtractor.cs
index 3358b29..3a47f5d 100644
--- a/mROA/Implementation/Backend/HubRequestExtractor.cs
+++ b/mROA/Implementation/Backend/HubRequestExtractor.cs
@@ -3,41 +3,28 @@ using mROA.Implementation.Frontend;
namespace mROA.Implementation.Backend
{
- public class HubRequestExtractor : IInjectableModule
+ public class HubRequestExtractor
{
- private IConnectionHub? _hub;
+ private IConnectionHub _hub;
- private IInstanceRepository? _contextRepository;
- private IInstanceRepository? _remoteContextRepository;
- private IMethodRepository? _methodRepository;
- private IContextualSerializationToolKit? _serializationToolkit;
- private IExecuteModule? _executeModule;
+ private IRealStoreInstanceRepository _contextRepository;
+ private IInstanceRepository _remoteContextRepository;
+ private IMethodRepository _methodRepository;
+ private IContextualSerializationToolKit _serializationToolkit;
+ private IExecuteModule _executeModule;
- public void Inject(object dependency)
+ public HubRequestExtractor(IConnectionHub hub, IRealStoreInstanceRepository contextRepository,
+ RemoteInstanceRepository remoteContextRepository, IMethodRepository methodRepository,
+ IContextualSerializationToolKit serializationToolkit, IExecuteModule executeModule)
{
- switch (dependency)
- {
- case IConnectionHub connectionHub:
- _hub = connectionHub;
- _hub.OnConnected += HubOnOnConnected;
- break;
- case MultiClientInstanceRepository:
- case InstanceRepository:
- _contextRepository = dependency as IInstanceRepository;
- break;
- case RemoteInstanceRepository remoteContextRepository:
- _remoteContextRepository = remoteContextRepository;
- break;
- case IMethodRepository methodRepository:
- _methodRepository = methodRepository;
- break;
- case IContextualSerializationToolKit serializationToolkit:
- _serializationToolkit = serializationToolkit;
- break;
- case IExecuteModule executeModule:
- _executeModule = executeModule;
- break;
- }
+ _hub = hub;
+ _hub.OnConnected += HubOnOnConnected;
+
+ _contextRepository = contextRepository;
+ _remoteContextRepository = remoteContextRepository;
+ _methodRepository = methodRepository;
+ _serializationToolkit = serializationToolkit;
+ _executeModule = executeModule;
}
private void HubOnOnConnected(IRepresentationModule interaction)
@@ -54,20 +41,15 @@ namespace mROA.Implementation.Backend
private IRequestExtractor CreateExtractor(IRepresentationModule interaction)
{
- var extractor = new RequestExtractor();
+ var extractor = new RequestExtractor(_executeModule, _methodRepository, interaction, _serializationToolkit, interaction.Context);
var context = interaction.Context;
- extractor.Inject(interaction);
if (_contextRepository is IContextRepositoryHub contextHub)
context.RealRepository = contextHub.GetRepository(interaction.Id);
else
- context.RealRepository = _contextRepository!;
+ context.RealRepository = _contextRepository;
- context.RemoteRepository = _remoteContextRepository!;
-
- extractor.Inject(context);
- extractor.Inject(_methodRepository);
- extractor.Inject(_serializationToolkit);
- extractor.Inject(_executeModule);
+ context.RemoteRepository = _remoteContextRepository;
+
return extractor;
}
}
diff --git a/mROA/Implementation/Backend/InstanceRepository.cs b/mROA/Implementation/Backend/InstanceRepository.cs
index c12c71c..f61f7f5 100644
--- a/mROA/Implementation/Backend/InstanceRepository.cs
+++ b/mROA/Implementation/Backend/InstanceRepository.cs
@@ -7,17 +7,18 @@ using mROA.Implementation.Attributes;
namespace mROA.Implementation.Backend
{
- public class InstanceRepository : IInstanceRepository
+ public class InstanceRepository : IRealStoreInstanceRepository
{
public static object[] EventBinders = { };
- private IRepresentationModuleProducer? _representationModuleProducer;
+ private IRepresentationModuleProducer _representationModuleProducer;
private Dictionary _singletons = new();
private readonly IStorage