From be6dedaee41b8077244f7ab9df991d839a19d2c9 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Tue, 4 Mar 2025 14:51:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B0=D0=B1=D1=81=D1=82=D1=80=D0=B0=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B1=D1=8D=D0=BA=D0=B5=D0=BD=D0=B4=D0=B0=20=D0=B2=D1=8B=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mROA.Codegen/mROASourceGenerator.cs | 11 ----- mROA/Abstract/IMethodRepository.cs | 6 +-- .../Backend/BasicConfigurationExtensions.cs | 5 -- mROA/Implementation/EndPointContext.cs | 7 ++- mROA/Implementation/MethodInvoker.cs | 14 +++++- mROA/Implementation/MethodRepository.cs | 47 ------------------- 6 files changed, 17 insertions(+), 73 deletions(-) delete mode 100644 mROA/Implementation/MethodRepository.cs diff --git a/mROA.Codegen/mROASourceGenerator.cs b/mROA.Codegen/mROASourceGenerator.cs index b0cd06c..28438f3 100644 --- a/mROA.Codegen/mROASourceGenerator.cs +++ b/mROA.Codegen/mROASourceGenerator.cs @@ -180,17 +180,6 @@ namespace mROA.Codegen return _methods[id]; }} - public int RegisterMethod(MethodInfo method) - {{ - _methods.Add(method); - return _methods.Count - 1; - }} - - public IEnumerable GetMethods() - {{ - return _methods; - }} - public void Inject(T dependency) {{ }} diff --git a/mROA/Abstract/IMethodRepository.cs b/mROA/Abstract/IMethodRepository.cs index 9e448f9..a08faf8 100644 --- a/mROA/Abstract/IMethodRepository.cs +++ b/mROA/Abstract/IMethodRepository.cs @@ -1,13 +1,9 @@ -using System.Collections.Generic; -using System.Reflection; +using System.Reflection; namespace mROA.Abstract { public interface IMethodRepository : IInjectableModule { MethodInfo GetMethod(int id); - int RegisterMethod(MethodInfo method); - - IEnumerable GetMethods(); } } \ No newline at end of file diff --git a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs b/mROA/Implementation/Backend/BasicConfigurationExtensions.cs index 16b1851..b7f2460 100644 --- a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs +++ b/mROA/Implementation/Backend/BasicConfigurationExtensions.cs @@ -8,11 +8,6 @@ namespace mROA.Implementation.Backend { public static class BasicConfigurationExtensions { - public static void UseJsonSerialisation(this FullMixBuilder builder) - { - builder.Modules.Add(new JsonSerializationToolkit()); - } - public static void UseNetworkGateway(this FullMixBuilder builder, IPEndPoint endPoint, Type interactionModuleType, params IInjectableModule[] injectableModules) { builder.Modules.Add(new NetworkGatewayModule(endPoint, interactionModuleType, injectableModules)); diff --git a/mROA/Implementation/EndPointContext.cs b/mROA/Implementation/EndPointContext.cs index 7ceb5df..1d80548 100644 --- a/mROA/Implementation/EndPointContext.cs +++ b/mROA/Implementation/EndPointContext.cs @@ -9,12 +9,11 @@ namespace mROA.Implementation public IContextRepository RealRepository { get; set; } public IContextRepository RemoteRepository { get; set; } public int HostId { get; set; } + public int OwnerId { get => OwnerFunc(); - set - { - OwnerFunc = () => value; - } } + set { OwnerFunc = () => value; } + } } } \ No newline at end of file diff --git a/mROA/Implementation/MethodInvoker.cs b/mROA/Implementation/MethodInvoker.cs index b49593f..337ec46 100644 --- a/mROA/Implementation/MethodInvoker.cs +++ b/mROA/Implementation/MethodInvoker.cs @@ -9,11 +9,23 @@ namespace mROA.Implementation public bool IsVoid { get; set; } public Type[] ParameterTypes { get; set; } = Type.EmptyTypes; public Type? ReturnType { get; set; } - public Func Invoking { get; set; } + public Func Invoking { get; set; } public object? Invoke(object instance, object?[] parameters, object[] special) { return Invoking(instance, parameters, special); } + + public static MethodInvoker Dispose = new MethodInvoker + { + IsAsync = false, + IsVoid = true, + ReturnType = null, + Invoking = ((instance, parameters, special) => + { + (instance as IDisposable)?.Dispose(); + return null; + }) + }; } } \ No newline at end of file diff --git a/mROA/Implementation/MethodRepository.cs b/mROA/Implementation/MethodRepository.cs deleted file mode 100644 index 020f7fc..0000000 --- a/mROA/Implementation/MethodRepository.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using mROA.Abstract; -using mROA.Implementation.Attributes; - -namespace mROA.Implementation -{ - public class MethodRepository : IMethodRepository - { - private readonly List _methods = new() { }; - - public MethodInfo GetMethod(int id) - { - if (_methods.Count <= id) - throw new Exception("Method such registered method"); - - return _methods[id]; - } - - public int RegisterMethod(MethodInfo method) - { - _methods.Add(method); - return _methods.Count - 1; - } - - public IEnumerable GetMethods() - { - return _methods; - } - - public void CollectForAssembly(Assembly assembly) - { - var types = assembly.GetTypes().Where(i => i.IsInterface && i.GetCustomAttributes(typeof(SharedObjectInterfaceAttribute), true).Length > 0); - foreach (var type in types) - { - foreach (var method in type.GetMethods()) - RegisterMethod(method); - } - } - public void Inject(T dependency) - { - - } - } -} \ No newline at end of file