public void Register <T>(Event.Handler handler) where T : Event { System.Type t = typeof(T); if (registeredHandlers.ContainsKey(t)) { registeredHandlers[t] += handler; } else { registeredHandlers[t] = handler; } }
public void Register <T>(Event.Handler handler) where T : Event { Type type = typeof(T); if (RegisteredHandlers.ContainsKey(type)) { RegisteredHandlers[type] += handler; } else { RegisteredHandlers[type] = handler; } }
public void Unregister <T>(Event.Handler handler) where T : Event { System.Type type = typeof(Event); Event.Handler handlers; if (registeredHandlers.TryGetValue(type, out handlers)) { handlers -= handler; if (handler == null) { registeredHandlers.Remove(type); } else { registeredHandlers[type] = handlers; } } }
public void UnRegister <T>(Event.Handler handler) where T : Event { Type type = typeof(T); Event.Handler handlers; if (RegisteredHandlers.TryGetValue(type, out handlers)) { handlers -= handler; if (handlers == null) { RegisteredHandlers.Remove(type); } else { RegisteredHandlers[type] = handlers; } } }
//Objects call this function to subscribe to events of a given type. //handler = The function to be called when the event occurs. //T = The type of the event. public void Register <T>(Event.Handler handler) where T : Event { Type type = typeof(T); /* * * If there's already an event of that type, add this handler to the list of handlers for that event. * If not, add that event to the dictionary, with this handler as the first item in the list. * Note that there's no explicit list; in C# delegates are both references to a function and a list of functions. * */ if (registeredHandlers.ContainsKey(type)) { registeredHandlers[type] += handler; } else { registeredHandlers[type] = handler; } }
/// <summary> /// Add new Managed event /// </summary> /// <param name="_condition">Condition function, event will fire when condition returns true</param> /// <param name="_eventAction">Event Handler Action with target type IEvent</param> /// <param name="_id">Optional event ID</param> /// <returns>Created event</returns> public static IEvent Add(Event.Condition _condition, Event.Handler <IEvent> _eventAction, string _id = null) { return(EventMgr.Add(_condition, _eventAction, 1, Defaults.EventPriority, DESC_USER_EVENT, _id)); }
public void RegisterRoute(string Path, Event.Handler Handler) { Handlers.Register(Path, Handler); }
public void OnConnect(Event.Handler Handler) { this.ClientConnect = (C) => { Event.Invoke(Handler, "Client", C); }; }
public void On(string Key, Event.Handler Handler) { RegisterRoute(Key, Handler); }
public SystemFunction(string Name, Event.Handler Handler, params string[] ArgNames) : base(Name) { this.Name = Name; this.Handler = Handler; this.Arguments = ArgNames; }
public void On(string Name, Event.Handler Func, string ThisName, object This) { this.AddEvent("On" + Name, Event.Wrapper(Func, "Bot", this, ThisName, This)); }
public void On(string Name, Event.Handler Func) { this.AddEvent("On" + Name, Event.Wrapper(Func, "Bot", this)); }