CTT/Server/Hotfix/Game/System/Other/GlobalMethodComponentSystem.cs

34 lines
1.4 KiB
C#
Raw Normal View History

2021-04-24 17:39:11 +08:00

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;
2021-09-07 16:20:46 +08:00
var action= methodInfo.CreateDelegate(typeof (Func<object,ETTask<string>>)) as Func<object,ETTask<string>>;
2021-04-24 17:39:11 +08:00
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;
2021-09-07 16:20:46 +08:00
var action= methodInfo.CreateDelegate(typeof (Func<object,ETTask<string>>)) as Func<object,ETTask<string>>;
2021-04-24 17:39:11 +08:00
self.methodDic.Add(methodInfo.Name,action);
}
}
}
}