Exemplo n.º 1
0
        /// <summary>
        ///     Raises the <see cref="DictionaryChanged" /> event.
        /// </summary>
        /// <param name="e">
        ///     The <see cref="System.Collections.NotifyDictionaryChangedEventArgs&lt;TKey,TValue&gt;" /> instance
        ///     containing the event data.
        /// </param>
        protected virtual void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <TKey, TValue> e)
        {
            EventHandler <NotifyDictionaryChangedEventArgs <TKey, TValue> > eventHandler = this.DictionaryChanged;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
Exemplo n.º 2
0
        protected void OnDictionaryChanged(object sender, NotifyDictionaryChangedEventArgs <TVertex, EdgeCollection <TVertex, TEdge> > e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:

                if (this.EdgeAdded != null)
                {
                    // Raise the event for each edge that was added.
                    foreach (var entry in e.NewItems)
                    {
                        foreach (var edge in entry.Value)
                        {
                            this.OnEdgeAdded(new EdgeEventArgs <TVertex, TEdge>(edge));
                        }
                    }
                }

                if (this.VertexAdded != null)
                {
                    // Raise the event for the vertex.
                    this.OnVertexAdded(new VertexEventArgs <TVertex>(e.NewItem.Key));
                }

                break;

            case NotifyCollectionChangedAction.Remove:

                if (this.EdgeRemoved != null)
                {
                    // Raise the event for each edge that was removed.
                    foreach (var entry in e.OldItems)
                    {
                        foreach (var edge in entry.Value)
                        {
                            this.OnEdgeRemoved(new EdgeEventArgs <TVertex, TEdge>(edge));
                        }
                    }
                }

                if (this.VertexRemoved != null)
                {
                    // Raise the event for the vertex.
                    this.OnVertexRemoved(new VertexEventArgs <TVertex>(e.OldItem.Key));
                }

                break;
            }
        }