コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 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);
 }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        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);
            }
        }