private void IdentityCollection_CollectionChangeAdded(object sender, IdentityCollectionAddEventArgs <T> e) { List <T> list = new List <T>(e.AddedItems); IdentityCollectionAddEventArgs <T> args = new IdentityCollectionAddEventArgs <T>(list); CollectionChangeAdded?.Invoke(this, args); }
/// <summary> /// Adds given item to collection, if collection does not contain this item. /// </summary> /// <param name="item">Item to add to collection.</param> public void AddItem(T item) { List <T> list = new List <T>(); if (Add(item)) { list.Add(item); IdentityCollectionAddEventArgs <T> args = new IdentityCollectionAddEventArgs <T>(list); CollectionChangeAdded?.Invoke(this, args); } }
public void AddRange(IEnumerable <T> items) { List <T> added = new List <T>(); foreach (T item in items) { if (Add(item, false)) { added.Add(item); } } if (added.Count > 0) { SelectionCollectionAddEventArgs <T> args = new SelectionCollectionAddEventArgs <T>(added); CollectionChangeAdded?.Invoke(this, args); } }
private bool Add(T item, bool sendEvent) { if (!allItems.Any(x => x.Id.Equals(item.Id))) { allItems.Add(item); if (sendEvent) { SelectionCollectionAddEventArgs <T> args = new SelectionCollectionAddEventArgs <T>(new List <T>() { item }); CollectionChangeAdded?.Invoke(this, args); } return(true); } return(false); }
/// <summary> /// Adds given items to collection, if collection does not contain these items. /// </summary> /// <param name="items">Items to add to collection.</param> public void AddRange(IEnumerable <T> items) { List <T> list = new List <T>(); foreach (T item in items) { if (Add(item)) { list.Add(item); } } if (list.Count > 0) { IdentityCollectionAddEventArgs <T> args = new IdentityCollectionAddEventArgs <T>(list); CollectionChangeAdded?.Invoke(this, args); } }
private void Add(IEnumerable <T> targetItems) { List <ISelectionItem <T> > added = new List <ISelectionItem <T> >(); foreach (T item in targetItems) { if (!allItems.Any(x => x.Target.Identifier.Id.Equals(item.Identifier.Id))) { ISelectionItem <T> selectionItem = new SelectionItem <T>(item); allItems.Add(selectionItem); added.Add(selectionItem); } } if (added.Count > 0) { SelectionCollectionAddEventArgs <T> args = new SelectionCollectionAddEventArgs <T>(added); CollectionChangeAdded?.Invoke(this, args); } }