private void Load() { this.handlers = new Dictionary <ushort, List <IInstanceMethod> >(); this.opcodeTypes = new DoubleMap <ushort, Type>(); Type[] monoTypes = DllHelper.GetMonoTypes(); foreach (Type monoType in monoTypes) { object[] attrs = monoType.GetCustomAttributes(typeof(MessageAttribute), false); if (attrs.Length == 0) { continue; } MessageAttribute messageAttribute = attrs[0] as MessageAttribute; if (messageAttribute == null) { continue; } this.opcodeTypes.Add(messageAttribute.Opcode, monoType); } #if ILRuntime Type[] types = DllHelper.GetHotfixTypes(); #else Type[] types = DllHelper.GetMonoTypes(); #endif foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(MessageHandlerAttribute), false); if (attrs.Length == 0) { continue; } MessageHandlerAttribute messageHandlerAttribute = (MessageHandlerAttribute)attrs[0]; #if ILRuntime IInstanceMethod method = new ILInstanceMethod(type, "Handle"); #else IInstanceMethod method = new MonoInstanceMethod(type, "Handle"); #endif if (!this.handlers.ContainsKey(messageHandlerAttribute.Opcode)) { this.handlers.Add(messageHandlerAttribute.Opcode, new List <IInstanceMethod>()); } this.handlers[messageHandlerAttribute.Opcode].Add(method); } }
private void Load() { this.allEvents = new Dictionary <int, List <IInstanceMethod> >(); Type[] types = DllHelper.GetMonoTypes(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; IInstanceMethod method = new MonoInstanceMethod(type, "Run"); if (!this.allEvents.ContainsKey(aEventAttribute.Type)) { this.allEvents.Add(aEventAttribute.Type, new List <IInstanceMethod>()); } this.allEvents[aEventAttribute.Type].Add(method); } } #if ILRuntime types = DllHelper.GetHotfixTypes(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; IInstanceMethod method = new ILInstanceMethod(type, "Run"); if (!this.allEvents.ContainsKey(aEventAttribute.Type)) { this.allEvents.Add(aEventAttribute.Type, new List <IInstanceMethod>()); } this.allEvents[aEventAttribute.Type].Add(method); } } #endif }