Третий пул рефакторинга

This commit is contained in:
2025-02-18 22:47:14 +03:00
parent eede46780b
commit 28afe465cc
5 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -4,5 +4,5 @@ namespace mROA.Abstract;
public interface IExecuteModule : IInjectableModule public interface IExecuteModule : IInjectableModule
{ {
ICommandExecution Execute(ICallRequest command, IContextRepository executionContextRepository); ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository);
} }
@@ -13,12 +13,12 @@ public class BasicExecutionModule : IExecuteModule
if (dependency is IMethodRepository methodRepo) _methodRepo = methodRepo; if (dependency is IMethodRepository methodRepo) _methodRepo = methodRepo;
} }
public ICommandExecution Execute(ICallRequest command, IContextRepository _contextRepo) public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository)
{ {
if (_methodRepo is null) if (_methodRepo is null)
throw new NullReferenceException("Method repository was not defined"); throw new NullReferenceException("Method repository was not defined");
if (_contextRepo is null) if (contextRepository is null)
throw new NullReferenceException("Context repository was not defined"); throw new NullReferenceException("Context repository was not defined");
var currentCommand = _methodRepo.GetMethod(command.CommandId); var currentCommand = _methodRepo.GetMethod(command.CommandId);
@@ -26,8 +26,8 @@ public class BasicExecutionModule : IExecuteModule
throw new Exception($"Command {command.CommandId} not found"); throw new Exception($"Command {command.CommandId} not found");
var context = command.ObjectId != -1 var context = command.ObjectId != -1
? _contextRepo.GetObject(command.ObjectId) ? contextRepository.GetObject(command.ObjectId)
: _contextRepo.GetSingleObject(currentCommand.DeclaringType!); : contextRepository.GetSingleObject(currentCommand.DeclaringType!);
var parameter = command.Parameter; var parameter = command.Parameter;
if (currentCommand.ReturnType.BaseType == typeof(Task) && if (currentCommand.ReturnType.BaseType == typeof(Task) &&
@@ -1,11 +1,10 @@
using mROA.Abstract; using mROA.Abstract;
using mROA.Implementation.Frontend;
namespace mROA.Implementation.Backend; namespace mROA.Implementation.Backend;
public class HubRequestExtractor(Type extractoType) : IInjectableModule public class HubRequestExtractor(Type extractoType) : IInjectableModule
{ {
private IConnectionHub _hub; private IConnectionHub? _hub;
private IContextRepository? _contextRepository; private IContextRepository? _contextRepository;
private IMethodRepository? _methodRepository; private IMethodRepository? _methodRepository;
@@ -27,6 +27,8 @@ public class NetworkFrontendBridge(IPEndPoint ipEndPoint) : IFrontendBridge
{ {
if (_interactionModule is null) if (_interactionModule is null)
throw new Exception("Interaction module was not injected"); throw new Exception("Interaction module was not injected");
if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized");
_tcpClient.Connect(ipEndPoint); _tcpClient.Connect(ipEndPoint);
_interactionModule.BaseStream = _tcpClient.GetStream(); _interactionModule.BaseStream = _tcpClient.GetStream();
@@ -1,4 +1,4 @@
namespace mROA.Implementation.Frontend;
// public class StreamBasedFrontendInteractionModule : IInteractionModule.IFrontendInteractionModule // public class StreamBasedFrontendInteractionModule : IInteractionModule.IFrontendInteractionModule
// { // {