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