private static void AddEntry(HookEntryType type, MethodBase method, Delegate hook) { object owner = GetOwner(hook); if (owner == null) { return; } if (!OwnedHookLists.TryGetValue(owner, out List <HookEntry> list)) { OwnedHookLists[owner] = list = new List <HookEntry>(); } list.Add(new HookEntry() { Type = type, Method = method, Hook = hook }); }
private static void RemoveEntry(HookEntryType type, MethodBase method, Delegate hook) { object owner = GetOwner(hook); if (owner == null) { return; } if (!OwnedHookLists.TryGetValue(owner, out List <HookEntry> list)) { return; } int index = list.FindLastIndex(entry => entry.Type.Equals(type) && entry.Method.Equals(method) && entry.Hook.Equals(hook)); if (index == -1) { return; } list.RemoveAt(index); }