|
|
@@ -130,15 +130,13 @@ namespace YSAI.Core.reflection
|
|
|
/// key 标识符,$"{ClassData.SN}{MethodData.SN}"
|
|
|
/// value (个个Dll反射的结果)
|
|
|
/// </summary>
|
|
|
- private ConcurrentDictionary<string, ReflectionMethodResult> MethodIocContainer;
|
|
|
+ private ConcurrentDictionary<string, ReflectionMethodResult> MethodIocContainer = new ConcurrentDictionary<string, ReflectionMethodResult>();
|
|
|
/// <summary>
|
|
|
/// 事件的IOC容器
|
|
|
/// key 标识符,$"{ClassData.SN}{MethodData.SN}"
|
|
|
/// value (个个Dll反射的结果)
|
|
|
/// </summary>
|
|
|
- private ConcurrentDictionary<string, ReflectionEventResult> EventIocContainer;
|
|
|
-
|
|
|
-
|
|
|
+ private ConcurrentDictionary<string, ReflectionEventResult> EventIocContainer = new ConcurrentDictionary<string, ReflectionEventResult>();
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -150,14 +148,6 @@ namespace YSAI.Core.reflection
|
|
|
Depart("Init");
|
|
|
try
|
|
|
{
|
|
|
- if (MethodIocContainer == null)
|
|
|
- {
|
|
|
- MethodIocContainer = new ConcurrentDictionary<string, ReflectionMethodResult>();
|
|
|
- }
|
|
|
- if (EventIocContainer == null)
|
|
|
- {
|
|
|
- EventIocContainer = new ConcurrentDictionary<string, ReflectionEventResult>();
|
|
|
- }
|
|
|
//得到DLL数据
|
|
|
foreach (var DllData in data.DllDatas)
|
|
|
{
|
|
|
@@ -258,10 +248,11 @@ namespace YSAI.Core.reflection
|
|
|
return Break("Init", false, ex.Message);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 创建实例
|
|
|
/// </summary>
|
|
|
- /// <param name="type">类型</param>
|
|
|
+ /// <param name="NamespaceAndClassNameType">类型</param>
|
|
|
/// <param name="ConstructorParam">构造函数入参</param>
|
|
|
/// <returns></returns>
|
|
|
private object? CreateInstance(Type? NamespaceAndClassNameType, object[]? ConstructorParam)
|
|
|
@@ -349,11 +340,11 @@ namespace YSAI.Core.reflection
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 执行方法
|
|
|
/// </summary>
|
|
|
- /// <param name="ClassSn">实例的唯一标识符</param>
|
|
|
- /// <param name="MethodSn">方法的唯一标识符</param>
|
|
|
+ /// <param name="SN">方法的唯一标识符</param>
|
|
|
/// <param name="MethodParam">方法参数</param>
|
|
|
/// <returns></returns>
|
|
|
public object? ExecuteMethod(string? SN, object[]? MethodParam = null)
|
|
|
@@ -371,7 +362,7 @@ namespace YSAI.Core.reflection
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return "执行失败,未找到反射的数据";
|
|
|
+ return Break(Depart("ExecuteMethod"),false, "执行失败,未找到反射的数据");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -414,7 +405,7 @@ namespace YSAI.Core.reflection
|
|
|
/// <param name="P5">五个参数的事件动作</param>
|
|
|
/// <param name="P6">六个参数的事件动作</param>
|
|
|
/// <returns></returns>
|
|
|
- public (bool state, string message) RegisterEvent(string SN, bool Register,
|
|
|
+ public OperateResult RegisterEvent(string SN, bool Register,
|
|
|
Action<object>? P1 = null,
|
|
|
Action<object, object>? P2 = null,
|
|
|
Action<object, object, object>? P3 = null,
|
|
|
@@ -422,6 +413,7 @@ namespace YSAI.Core.reflection
|
|
|
Action<object, object, object, object, object>? P5 = null,
|
|
|
Action<object, object, object, object, object, object>? P6 = null)
|
|
|
{
|
|
|
+ Depart("RegisterEvent");
|
|
|
ReflectionEventResult? reflectionEventResult = GetEvent(SN);
|
|
|
if (reflectionEventResult != null)
|
|
|
{
|
|
|
@@ -460,16 +452,16 @@ namespace YSAI.Core.reflection
|
|
|
{
|
|
|
reflectionEventResult.Event.RemoveEventHandler(reflectionEventResult.InstanceObject, @delegate);
|
|
|
}
|
|
|
- return (true, "事件注册成功");
|
|
|
+ return Break("RegisterEvent", true, "事件注册成功");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return (false, "事件注册失败,未找到反射的数据类型");
|
|
|
+ return Break("RegisterEvent", false, "事件注册失败,未找到反射的数据类型");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return (false, "事件注册失败,未找到反射的数据");
|
|
|
+ return Break("RegisterEvent", false, "事件注册失败,未找到反射的数据");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -501,6 +493,8 @@ namespace YSAI.Core.reflection
|
|
|
|
|
|
public void Dispose()
|
|
|
{
|
|
|
+ MethodIocContainer.Clear();
|
|
|
+ EventIocContainer.Clear();
|
|
|
GC.Collect();
|
|
|
}
|
|
|
}
|