Упрощение абстракции и первый код нового бэкенда вызова
This commit is contained in:
@@ -180,17 +180,6 @@ namespace mROA.Codegen
|
||||
return _methods[id];
|
||||
}}
|
||||
|
||||
public int RegisterMethod(MethodInfo method)
|
||||
{{
|
||||
_methods.Add(method);
|
||||
return _methods.Count - 1;
|
||||
}}
|
||||
|
||||
public IEnumerable<MethodInfo> GetMethods()
|
||||
{{
|
||||
return _methods;
|
||||
}}
|
||||
|
||||
public void Inject<T>(T dependency)
|
||||
{{
|
||||
}}
|
||||
|
||||
@@ -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<MethodInfo> GetMethods();
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<object?, object, object?[], object[]> Invoking { get; set; }
|
||||
public Func<object, object?[], object[], object?> 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;
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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<MethodInfo> _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<MethodInfo> 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>(T dependency)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user