using System.Collections.Concurrent; using System.Reflection; using NetCore; using NetServerCore.Attribute; using NetServerCore.Tool; namespace NetServerCore.NetLink; public class LogicManagerBaisc : ILogicalParsing { private ConcurrentDictionary> _allLogic = new ConcurrentDictionary>(); public void Init(string assemblyName, int groid) { Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < ass.Length; i++) { Assembly assembly = ass[i]; if (!assembly.GetName().Name.Equals(assemblyName)) { continue; } Type[] allType = assembly.GetTypes(); for (int j = 0; j < allType.Length; j++) { Type type = allType[j]; LogicEnrollAtt logicEnrollAtt = type.GetCustomAttribute(); if (logicEnrollAtt != null && logicEnrollAtt.group == groid) { LogicBaisc logicBasic = Activator.CreateInstance(type) as LogicBaisc; logicBasic.Init(this); _allLogic.TryAdd(logicEnrollAtt.index, logicBasic); } } } } public LogicBaisc GetLogicBaisc(int type) { LogicBaisc logicBaisc; if (_allLogic.TryGetValue(type, out logicBaisc)) { return logicBaisc; } return null; } public virtual void Logic(object data, IConnection iConnection) { } public virtual void AddConnection(IConnection iConnection) { } public virtual void RemoveConnection(IConnection iConnection) { } }