public virtual void OnEnable() { MethodInfo[] methods = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo m in methods) { System.Attribute[] attributes = (System.Attribute[])m.GetCustomAttributes(true); foreach (System.Attribute attribute in attributes) { if (attribute is OnEvent) { OnEvent onEventMethod = (OnEvent)attribute; if (m.GetParameters().Length == 2) { PMEvent del = (PMEvent)Delegate.CreateDelegate(typeof(PMEvent), this, m); events.Add(new PairEventString(onEventMethod.Name, del)); } else { PMEventLite del = (PMEventLite)Delegate.CreateDelegate(typeof(PMEventLite), this, m); eventsLite.Add(new PairEventLiteString(onEventMethod.Name, del)); } } } } RegisterAll(); }
public void Unregister(string id, PMEvent eventMethod) { if (id != "") { events [id] -= eventMethod; } else { allEvents -= eventMethod; } }
public void Initialize() { StateController.AddPieka(this); System.Attribute[] att = (System.Attribute[])GetType().GetCustomAttributes(true); foreach (System.Attribute attribute in att) { if (attribute is AllowedState) { AllowedState allowedState = (AllowedState)attribute; isInActiveState = false; allowedStates.Add(allowedState.Name); } } MethodInfo[] methods = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo m in methods) { System.Attribute[] attributes = (System.Attribute[])m.GetCustomAttributes(true); foreach (System.Attribute attribute in attributes) { if (attribute is OnEvent) { OnEvent onEventMethod = (OnEvent)attribute; if (m.GetParameters().Length == 2) { PMEvent del = (PMEvent)Delegate.CreateDelegate(typeof(PMEvent), this, m); events.Add(new PairEventString(onEventMethod.Name, del)); } else { PMEventLite del = (PMEventLite)Delegate.CreateDelegate(typeof(PMEventLite), this, m); eventsLite.Add(new PairEventLiteString(onEventMethod.Name, del)); } // SEventSystem.Register ( onEventMethod.Name, (PMEvent)PMEvent.CreateDelegate( typeof(PMEvent), m ) ); } } } RegisterAll(); OnStateChange(StateController.GetActiveState()); }
public void Register(string id, PMEvent eventMethod) { if (id != "") { if (!events.ContainsKey(id)) { events [id] = eventMethod; } else { events [id] += eventMethod; } } else { allEvents += eventMethod; } }
public static void Unregister(string id, PMEvent eventMethod) { eventSystem.Unregister(id, eventMethod); }
private void dateTimePicker_ValueChanged(object sender, EventArgs e) { datetime = dateTimePicker.Value; DisplayPD(datetime); PMEvent?.Invoke(this, e); }
public PairEventString(string name, PMEvent @event) { this.Name = name; this.Event = @event; }