34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
|
|
|||
|
using System;
|
|||
|
using System.Reflection;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class GlobalMethodComponentAwakeSystem:AwakeSystem<GlobalMethodComponent>
|
|||
|
{
|
|||
|
public override void Awake(GlobalMethodComponent self)
|
|||
|
{
|
|||
|
foreach (MethodInfo methodInfo in typeof(GlobalMethod).GetMethods(BindingFlags.Public | BindingFlags.Static))
|
|||
|
{
|
|||
|
DataTableMethodAttribute attribute= methodInfo.GetCustomAttribute<DataTableMethodAttribute>();
|
|||
|
if (attribute == null) continue;
|
|||
|
var action= methodInfo.CreateDelegate(typeof (Action<string[]>)) as Action<string[]>;
|
|||
|
self.methodDic.Add(methodInfo.Name,action);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public class GlobalMethodComponentLoadSystem:LoadSystem<GlobalMethodComponent>
|
|||
|
{
|
|||
|
public override void Load(GlobalMethodComponent self)
|
|||
|
{
|
|||
|
self.methodDic.Clear();
|
|||
|
foreach (MethodInfo methodInfo in typeof(GlobalMethod).GetMethods(BindingFlags.Public | BindingFlags.Static))
|
|||
|
{
|
|||
|
DataTableMethodAttribute attribute= methodInfo.GetCustomAttribute<DataTableMethodAttribute>();
|
|||
|
if (attribute == null) continue;
|
|||
|
var action= methodInfo.CreateDelegate(typeof (Action<string[]>)) as Action<string[]>;
|
|||
|
self.methodDic.Add(methodInfo.Name,action);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|