public virtual void RegisterListener() { if (EventSource != null) { EventSource.AddListener(this); } if (raiseOnBind) { ValueChanged.Invoke(EventSource.DataValue); } }
protected EventListener() { lock (EventListener.EventListenersLock) { foreach (WeakReference sEventSource in EventListener.s_EventSources) { EventSource target = sEventSource.Target as EventSource; if (target == null) { continue; } target.AddListener(this); } this.m_Next = EventListener.s_Listeners; EventListener.s_Listeners = this; } }
internal static void AddEventSource(EventSource newEventSource) { WeakReference item; lock (EventListener.EventListenersLock) { if (EventListener.s_EventSources == null) { EventListener.s_EventSources = new List <WeakReference>(2); } int count = -1; if (EventListener.s_EventSources.Count % 64 == 63) { int num = EventListener.s_EventSources.Count; do { if (0 >= num) { goto Label0; } num--; item = EventListener.s_EventSources[num]; }while (item.IsAlive); count = num; item.Target = newEventSource; } Label0: if (count < 0) { count = EventListener.s_EventSources.Count; EventListener.s_EventSources.Add(new WeakReference(newEventSource)); } newEventSource.m_id = count; for (EventListener i = EventListener.s_Listeners; i != null; i = i.m_Next) { newEventSource.AddListener(i); } } }