From b366ca26ccbd534328d1f26204febfa1b8b590c7 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Thu, 13 Mar 2025 20:36:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=80=D0=B5=D1=84?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backend/BasicExecutionModule.cs | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs index 21e4663..25b96c1 100644 --- a/mROA/Implementation/Backend/BasicExecutionModule.cs +++ b/mROA/Implementation/Backend/BasicExecutionModule.cs @@ -42,16 +42,14 @@ namespace mROA.Implementation.Backend #if TRACE Console.WriteLine("Final cancelling request"); #endif - CancelExecution(command); + return CancelExecution(command); } var invoker = _methodRepo!.GetMethod(command.CommandId); if (invoker == null) throw new Exception($"Command {command.CommandId} not found"); - var context = command.ObjectId.ContextId != -1 - ? contextRepository.GetObject(command.ObjectId) - : contextRepository.GetSingleObject(invoker.SuitableType, command.ObjectId.OwnerId); + var context = GetContext(command, contextRepository, invoker); if (context == null) throw new NullReferenceException("Instance can't be null"); @@ -60,13 +58,8 @@ namespace mROA.Implementation.Backend object?[]? castedParams = null; if (invoker.ParameterTypes.Length != 0) - { - castedParams = new object[invoker.ParameterTypes.Length]; - for (var i = 0; i < castedParams.Length; i++) - { - castedParams[i] = _serialization!.Cast(command.Parameters![i], invoker.ParameterTypes[i]); - } - } + castedParams = CastedParams(command, invoker); + var execContext = new RequestContext(command.Id, representationModule.Id); @@ -102,6 +95,25 @@ namespace mROA.Implementation.Backend } } + private static object GetContext(ICallRequest command, IContextRepository contextRepository, IMethodInvoker invoker) + { + var context = command.ObjectId.ContextId != -1 + ? contextRepository.GetObject(command.ObjectId) + : contextRepository.GetSingleObject(invoker.SuitableType, command.ObjectId.OwnerId); + return context; + } + + private object?[] CastedParams(ICallRequest command, IMethodInvoker invoker) + { + 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]); + } + + return castedParams; + } + private void ThrowIfNotInjected(IContextRepository contextRepository) { if (_cancellationRepo is null) @@ -127,7 +139,7 @@ namespace mROA.Implementation.Backend Id = command.Id }; } - + private static ICommandExecution Execute(MethodInvoker invoker, object instance, object?[] parameter, ICallRequest command, RequestContext executionContext) {