private NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, TKey key = default(TKey), TValue oldValue = default(TValue), TValue newValue = default(TValue))
 {
     _action   = action;
     _key      = key;
     _oldValue = oldValue;
     _newValue = newValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}"/> class that describes a <see cref="NotifyDictionaryChangedAction.Reset"/> change
 /// </summary>
 /// <param name="action">The action that caused the event (this must be set to <see cref="NotifyDictionaryChangedAction.Reset"/>)</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action)
 {
     if (action != NotifyDictionaryChangedAction.Reset)
     {
         throw new ArgumentOutOfRangeException(nameof(action));
     }
     InitializeAdd(action);
 }
 /// <summary>
 /// Construct a NotifyDictionaryChangedEventArgs that describes a reset change.
 /// </summary>
 /// <param name="action">The action that caused the event; must be Reset action.</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action)
 {
     if (action != NotifyDictionaryChangedAction.Reset)
     {
         throw new ArgumentException(SR.GetString(SR.WrongActionForCtor, NotifyDictionaryChangedAction.Reset), nameof(action));
     }
     InitializeAdd(action, null, null);
 }
 private void InitializeReplace(NotifyDictionaryChangedAction action, IList <object> keys, IList <object> oldItems, IList <object> newItems)
 {
     Action   = action;
     NewItems = newItems;
     NewKeys  = keys;
     OldItems = oldItems;
     OldKeys  = keys;
 }
 void InitializeRemove(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> >?oldItems)
 {
     Action = action;
     if (oldItems is IEnumerable <KeyValuePair <TKey, TValue> > actualOldItems)
     {
         OldItems = actualOldItems.ToImmutableArray();
     }
 }
 void InitializeAdd(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> >?newItems = null)
 {
     Action = action;
     if (newItems is IEnumerable <KeyValuePair <TKey, TValue> > actualNewItems)
     {
         NewItems = actualNewItems.ToImmutableArray();
     }
 }
 /// <summary>
 /// Construct a NotifyDictionaryChangedEventArgs that describes a one-item Replace event, can only be Replace.
 /// </summary>
 /// <param name="action">Can only be a Replace action.</param>
 /// <param name="newItem">The new item replacing the original item.</param>
 /// <param name="oldItem">The original item that is replaced.</param>
 /// <param name="key">Keys of items that have been replaced.</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, object key, object oldItem, object newItem)
 {
     if (action != NotifyDictionaryChangedAction.Replace)
     {
         throw new ArgumentException(SR.GetString(SR.WrongActionForCtor, NotifyDictionaryChangedAction.Replace), "action");
     }
     InitializeReplace(action, new[] { key }, new[] { oldItem }, new[] { newItem });
 }
Exemplo n.º 8
0
        private NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, TKey key = default, TValue oldValue = default, TValue newValue = default)
        {
            Debug.Assert(Enum.IsDefined(typeof(NotifyDictionaryChangedAction), action));

            _action   = action;
            _key      = key;
            _oldValue = oldValue;
            _newValue = newValue;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}"/> class that describes a multi-item <see cref="NotifyDictionaryChangedAction.Replace"/> change
 /// </summary>
 /// <param name="action">The action that caused the event (this must be set to <see cref="NotifyDictionaryChangedAction.Replace"/>)</param>
 /// <param name="newItems">The new key-value pairs that are replacing the original key-value pairs</param>
 /// <param name="oldItems">The original key-value pairs that are replaced</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> > newItems, IEnumerable <KeyValuePair <TKey, TValue> > oldItems)
 {
     if (action != NotifyDictionaryChangedAction.Replace)
     {
         throw new ArgumentOutOfRangeException(nameof(action));
     }
     InitializeAdd(action, newItems);
     InitializeRemove(action, oldItems);
 }
Exemplo n.º 10
0
        private NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, TKey?key = default, TValue?oldValue = default, TValue?newValue = default)
        {
            Assert(AssertionsEnabled && Enum.IsDefined(action));

            _action   = action;
            _key      = key;
            _oldValue = oldValue;
            _newValue = newValue;
        }
 /// <summary>
 /// Construct a NotifyDictionaryChangedEventArgs that describes a one-item change.
 /// </summary>
 /// <param name="action">The action that caused the event; must be Add or Remove action.</param>
 /// <param name="changedItem">The item affected by the change.</param>
 /// <param name="key">The key where the change occurred.</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, object key, object changedItem)
 {
     if (action == NotifyDictionaryChangedAction.Add)
     {
         InitializeAdd(action, new[] { key }, new[] { changedItem });
     }
     else if (action == NotifyDictionaryChangedAction.Remove)
     {
         InitializeRemove(action, new[] { key }, new[] { changedItem });
     }
     else
     {
         throw new ArgumentException(SR.GetString(SR.MustBeResetAddOrRemoveActionForCtor), "action");
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}"/> class that describes a multi-item change
        /// </summary>
        /// <param name="action">The action that caused the event (this must be set to <see cref="NotifyDictionaryChangedAction.Add"/> or <see cref="NotifyDictionaryChangedAction.Remove"/>)</param>
        /// <param name="changedItems">The items that are affected by the change</param>
        public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> > changedItems)
        {
            switch (action)
            {
            case NotifyDictionaryChangedAction.Add:
                InitializeAdd(action, changedItems);
                break;

            case NotifyDictionaryChangedAction.Remove:
                InitializeRemove(action, changedItems);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(action));
            }
        }
 /// <summary>
 /// Construct a NotifyDictionaryChangedEventArgs that describes a multi-item Replace event.
 /// </summary>
 /// <param name="action">Can only be a Replace action.</param>
 /// <param name="newItems">The new items replacing the original items.</param>
 /// <param name="oldItems">The original items that are replaced.</param>
 /// <param name="keys">Keys of items that have been replaced.</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, IList <object> keys, IList <object> newItems, IList <object> oldItems)
 {
     if (action != NotifyDictionaryChangedAction.Replace)
     {
         throw new ArgumentException(SR.GetString(SR.WrongActionForCtor, NotifyDictionaryChangedAction.Replace), "action");
     }
     if (newItems == null)
     {
         throw new ArgumentNullException("newItems");
     }
     if (oldItems == null)
     {
         throw new ArgumentNullException("oldItems");
     }
     InitializeReplace(action, keys, oldItems, newItems);
 }
Exemplo n.º 14
0
        public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, ICollection <KeyValuePair <TKey, TValue> > items)
        {
            Action = action;

            switch (action)
            {
            case NotifyDictionaryChangedAction.Add:
                NewItems = items;
                break;

            case NotifyDictionaryChangedAction.Remove:
                OldItems = items;
                break;

            default:
                throw new ArgumentException($"Action must be {nameof(NotifyDictionaryChangedAction.Add)} or {nameof(NotifyDictionaryChangedAction.Remove)}.", nameof(action));
            }
        }
        /// <summary>
        /// Construct a NotifyDictionaryChangedEventArgs that describes a multi-item change; can only be Add or Remove action.
        /// </summary>
        /// <param name="action">The action that caused the event.</param>
        /// <param name="changedItems">The items affected by the change.</param>
        /// <param name="keys">Keys of items that have been changed.</param>
        public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, IList <object> keys, IList <object> changedItems)
        {
            if (changedItems == null)
            {
                throw new ArgumentNullException("changedItems");
            }
            if (keys == null || keys.Count == 0)
            {
                throw new ArgumentException(SR.GetString(SR.KeyMustNotBeNullOrZeroLength), "Keys");
            }

            if (action == NotifyDictionaryChangedAction.Add)
            {
                InitializeAdd(action, keys, changedItems);
            }
            else if (action == NotifyDictionaryChangedAction.Remove)
            {
                InitializeRemove(action, keys, changedItems);
            }
            else
            {
                throw new ArgumentException(SR.GetString(SR.MustBeResetAddOrRemoveActionForCtor), "action");
            }
        }
Exemplo n.º 16
0
 internal NotifyDictionaryChangedEventArgs(TValue item, NotifyDictionaryChangedAction action)
 {
     Items  = new TValue[] { item };
     Action = action;
 }
Exemplo n.º 17
0
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, TKey key, TValue changedItem) : base(action, key, changedItem)
 {
 }
Exemplo n.º 18
0
 public DictionaryChangedEventArgs(NotifyDictionaryChangedAction action, ICollection <KeyValuePair <TKey, TValue> > oldItems, ICollection <KeyValuePair <TKey, TValue> > newItems)
 {
     Action   = action;
     OldItems = oldItems;
     NewItems = newItems;
 }
 void InitializeAdd(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> > newItems = null)
 {
     Action   = action;
     NewItems = newItems?.ToImmutableArray();
 }
 private void InitializeRemove(NotifyDictionaryChangedAction action, IList <object> oldKeys, IList <object> oldItems)
 {
     Action   = action;
     OldItems = oldItems;
     OldKeys  = oldKeys;
 }
 private void InitializeAdd(NotifyDictionaryChangedAction action, IList <object> newKeys, IList <object> newItems)
 {
     Action   = action;
     NewItems = newItems;
     NewKeys  = newKeys;
 }
 void InitializeRemove(NotifyDictionaryChangedAction action, IEnumerable <KeyValuePair <TKey, TValue> > oldItems)
 {
     Action   = action;
     OldItems = oldItems?.ToImmutableArray();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}"/> class that describes a one-item <see cref="NotifyDictionaryChangedAction.Replace"/> change
 /// </summary>
 /// <param name="action">The action that caused the event (this must be set to <see cref="NotifyDictionaryChangedAction.Replace"/>)</param>
 /// <param name="key">The key of the item that is affected by the change</param>
 /// <param name="newValue">The new value that is replacing the original value</param>
 /// <param name="oldValue">The original value that is replaced</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, TKey key, TValue newValue, TValue oldValue) : this(action, new KeyValuePair <TKey, TValue>(key, newValue), new KeyValuePair <TKey, TValue>(key, oldValue))
 {
 }
Exemplo n.º 24
0
 public NotifyDictionaryChangedEventArgs(KeyValuePair <TKey, TValue> newItem, KeyValuePair <TKey, TValue> oldItem)
 {
     Action   = NotifyDictionaryChangedAction.Replace;
     NewItems = new[] { newItem };
     OldItems = new[] { oldItem };
 }
Exemplo n.º 25
0
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, KeyValuePair <TKey, TValue> item)
     : this(action, new[] { item })
 {
 }
Exemplo n.º 26
0
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action) : base(action)
 {
 }
 public NotifyDictionaryTransactionalEventArgsMock(TransactionMock transaction, NotifyDictionaryChangedAction action) : base(action)
 {
     this.transaction = transaction;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}"/> class that describes a one-item <see cref="NotifyDictionaryChangedAction.Replace"/> change
 /// </summary>
 /// <param name="action">The action that caused the event (this must be set to <see cref="NotifyDictionaryChangedAction.Replace"/>)</param>
 /// <param name="newItem">The new key-value pair that is replacing the original key-value pair</param>
 /// <param name="oldItem">The original key-value pair that is replaced</param>
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, KeyValuePair <TKey, TValue> newItem, KeyValuePair <TKey, TValue> oldItem) : this(action, new KeyValuePair <TKey, TValue>[] { newItem }, new KeyValuePair <TKey, TValue>[] { oldItem })
 {
 }
Exemplo n.º 29
0
 internal NotifyDictionaryChangedEventArgs(IEnumerable <TValue> items, NotifyDictionaryChangedAction action)
 {
     Items  = items;
     Action = action;
 }
Exemplo n.º 30
0
 public NotifyDictionaryChangedEventArgs(NotifyDictionaryChangedAction action, IList <TKey> keys, IList <TValue> newItems, IList <TValue> oldItems) : base(action, keys, newItems, oldItems)
 {
 }