Пример #1
0
        ///  <summary>
        ///  Dispatches the specified event to each listener.
        ///  </summary>
        /// <param name="eventType">Event type</param>
        /// <param name="item">Item</param>
        private void DispatchEvent(int eventType, TItem item)
        {
            object[] listenerSet;
            lock (_registeredListener) {
                listenerSet = _registeredListener.ToArray();
            }

            for (int i = -1; ++i != listenerSet.Length;)
            {
                object rawObj = listenerSet[i];
                IEnumerableListener         rawListener = rawObj as IEnumerableListener;
                IEnumerableListener <TItem> genListener = rawObj as IEnumerableListener <TItem>;

                if (eventType == AddEvent)
                {
                    rawListener?.OnItemAdded(this, item);
                    genListener?.OnItemAdded(this, item);
                    continue;
                }

                if (eventType == RemoveEvent)
                {
                    rawListener?.OnItemRemoved(this, item);
                    genListener?.OnItemRemoved(this, item);
                    continue;
                }

                if (eventType == ClearEvent)
                {
                    rawListener?.OnCleared(this);
                    genListener?.OnCleared(this);
                }
            }
        }
 /// <inheritdoc />
 void IObservableEnumerable.RemoveListener(IEnumerableListener listener)
 {
     _listener.Remove(listener);
 }
 /// <inheritdoc />
 void IObservableEnumerable.AddListener(IEnumerableListener listener)
 {
     _listener.Add(listener);
 }
 /// <inheritdoc />
 public void RemoveListener(IEnumerableListener <TElement> listener)
 {
     _genericListener.Remove(listener);
 }
 /// <inheritdoc />
 public void AddListener(IEnumerableListener <TElement> listener)
 {
     _genericListener.Add(listener);
 }
Пример #6
0
 /// <inheritdoc />
 void IObservableEnumerable.RemoveListener(IEnumerableListener listener)
 {
     RemoveListenerInstance(listener);
 }
Пример #7
0
 /// <inheritdoc />
 public void RemoveListener(IEnumerableListener <TItem> listener)
 {
     RemoveListenerInstance(listener);
 }
Пример #8
0
 /// <inheritdoc />
 void IObservableEnumerable.AddListener(IEnumerableListener listener)
 {
     AddListenerInstance(listener);
 }
Пример #9
0
 /// <inheritdoc />
 public void AddListener(IEnumerableListener <TItem> listener)
 {
     AddListenerInstance(listener);
 }