/// <summary>
 /// Initializes a new instance of <see cref="CollectionChangedEventRaiser{T}"/>.
 /// </summary>
 /// <param name="dlg">The <see cref="CollectionChangedEventHandler{TItem}"/> delegate to call.</param>
 /// <param name="notifyingCollection">The collection owning the item to notify.</param>
 /// <param name="itemToNotify">The item to use as parameter for the <see cref="CollectionChangedEventHandler{TItem}"/> delegate.</param>
 /// <param name="args">The event data.</param>
 /// <param name="syncLock">The object to lock when reading the delegate.</param>
 public CollectionChangedEventRaiser(CollectionChangedEventHandler <T> dlg, ICollection <T> notifyingCollection, T itemToNotify, EventArgs args, object syncLock)
 {
     _delegate     = dlg;
     _collection   = notifyingCollection;
     _itemToNotify = itemToNotify;
     _args         = args;
     _syncLock     = syncLock;
 }
Exemple #2
0
 /// <summary>
 /// プロパティが変更されたときに呼び出されるハンドラを削除する。
 /// </summary>
 /// <param name="name"></param>
 /// <param name="h"></param>
 public void RemovePropertyChangedHandler(CollectionChangedEventHandler h)
 {
     lock (lockObject)
     {
         var current = propertyObject;
         current.handler -= h;
     }
 }
        public void Subscribe(CollectionChangedEventHandler <KeyValuePair <string, DataElement> > handler)
        {
            if (_handlers.Contains(handler))
            {
                return;
            }

            _handlers.Add(handler);
        }
Exemple #4
0
            internal void OnCollectionChanged(int index, int size_delta)
            {
                CollectionChangedEventHandler handler = CollectionChanged;

                if (handler != null)
                {
                    handler(index, size_delta);
                }
            }
Exemple #5
0
        private void RaiseCollectionChangedEvent()
        {
            CollectionChangedEventHandler handler = this.CollectionChanged;

            if (handler != null)
            {
                handler(this, CollectionChangedEventArgs.Reset);
            }
        }
Exemple #6
0
 public void AddPropertyChangedHandler(CollectionChangedEventHandler h, Control form = null)
 {
     lock (lockObject)
     {
         var current = propertyObject;
         current.handler += h;
         current.form     = form; // 上書きする
     }
 }
        public void Subscribe(CollectionChangedEventHandler <DataElement> handler)
        {
            if (_handlers.Contains(handler))
            {
                return;
            }

            _handlers.Add(handler);
        }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cp"></param>
 private void OnCollectionChanged(ChangedType changedType, CommuniPort cp)
 {
     if (this.CollectionChanged != null)
     {
         CollectionChangedEventHandler temp = this.CollectionChanged;
         CollectionChangedEventArgs    e    = new CollectionChangedEventArgs(
             //ChangedType.Add,
             changedType,
             cp);
         temp(this, e);
     }
 }
 public void UnSubscribe(CollectionChangedEventHandler <KeyValuePair <string, DataElement> > handler)
 {
     _handlers.Remove(handler);
 }
 public void Subscribe(IRetainer <CollectionChangedEventHandler <KeyValuePair <string, DataElement> > > target, CollectionChangedEventHandler <KeyValuePair <string, DataElement> > handler)
 {
     _autoReleaseHandlers.Add(new WeakReference <CollectionChangedEventHandler <KeyValuePair <string, DataElement> > >(handler));
     target.Retain(handler);
 }
 /// <summary>
 /// Initializes a new instance of <see cref="CollectionChangedEventRaiser{T}"/>.
 /// </summary>
 /// <param name="dlg">The <see cref="CollectionChangedEventHandler{TItem}"/> delegate to call.</param>
 /// <param name="notifyingCollection">The collection owning the item to notify.</param>
 /// <param name="itemToNotify">The item to use as parameter for the <see cref="CollectionChangedEventHandler{TItem}"/> delegate.</param>
 /// <param name="args">The event data.</param>
 public CollectionChangedEventRaiser(CollectionChangedEventHandler <T> dlg, ICollection <T> notifyingCollection, T itemToNotify, EventArgs args)
     : this(dlg, notifyingCollection, itemToNotify, args, new object())
 {
 }
 public void UnSubscribe(CollectionChangedEventHandler <DataElement> handler)
 {
     _handlers.Remove(handler);
 }