public static void Create(HOOKS hook, string identifier) { int index = HookToIndex(hook); if (System.Diagnostics.Debugger.IsAttached){ if (index < hooks.Length ? hooks[index] != null : false) throw new Exception(String.Format("Error: Hook index '{0}' already exists.", index)); if (hookStrings.ContainsKey(identifier)) throw new Exception(String.Format("Error: Hook indentifier '{0}' already exists.", identifier)); } if (index >= hooks.Length) Array.Resize(ref hooks, index + 1); //As we're using primitive arrays, resize if the id is larger than the allocated size hooks[index] = new List<Item>(){}; hookStrings.Add(identifier, index); }
public static void Add(HOOKS hook, Action funct) { AddFunct(GetActionList(HookToIndex(hook)), new ItemNoPara(funct)); }
public static void Add(HOOKS hook, Action<System.Object[]> funct) { AddFunct(GetActionList(HookToIndex(hook)), new Item(funct)); }
private static int HookToIndex(HOOKS hook) { return (int) hook; }
public static void Call(HOOKS hook, params System.Object[] para) { Item.para = para; Call(hook); }
public static void Call(HOOKS hook) { GetActionList(HookToIndex(hook)).ForEach(Invoke); }