static public void Invoke(string eventName, object sender) { EventDescription[] items = MessengerList.GetElements(eventName); if (items.Length > 0) { foreach (EventDescription item in items) { item.Execute(sender, EventArgs.Empty); } } }
static public void Invoke <TEventArgs>(string eventName, object sender, TEventArgs eventargs) where TEventArgs : EventArgs { EventDescription <TEventArgs>[] items = MessengerList <TEventArgs> .GetElements(eventName); if (items.Length > 0) { foreach (EventDescription <TEventArgs> item in items) { item.Execute(sender, eventargs); } } }
public void CreateMessengers() { for (var i = 0; i < AreaArray.Count; i++) { for (var j = 0; j < Config.MessengersCount / AreaArray.Count; j++) { var tempPosition = SetAgentPosition(); SetAgentVelocity(tempPosition); var sId = "M" + i + j; var tempAgent = new Messenger(Config, tempPosition, sId, this, AreaArray[i]); MessengerList.Add(tempAgent); } } }
static public void AddListener(string eventName, EventHandler handler, float timeout = 0) { MessengerList.Add(eventName, handler, timeout); }
static public void RemoveListener <TEventArgs>(string eventName, EventHandler <TEventArgs> handler, float timeout = 0) where TEventArgs : EventArgs { MessengerList <TEventArgs> .Remove(eventName, handler, timeout); }