using System; using System.Reflection; using System.Collections.Generic; namespace FiestaBot.Instances.Handlers { internal class HandlerLoader { public Dictionary> Handlers; public HandlerLoader() { Handlers = new Dictionary>(); } public bool HasHandler(byte Header, byte Type) { if (Handlers.ContainsKey(Header)) { if (Handlers[Header].ContainsKey(Type)) { return true; } } return false; } public MethodInfo GetHandler(byte Header, byte Type) { Dictionary HeaderDictionary; MethodInfo TypeMethod; if (Handlers.TryGetValue(Header, out HeaderDictionary)) { if (HeaderDictionary.TryGetValue(Type, out TypeMethod)) { return TypeMethod; } } return null; } public Action GetAction(MethodInfo TypeMethod, params object[] Args) { return () => TypeMethod.Invoke(null, Args); } } }