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);
        }
Esempio n. 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);
            }
        }
Esempio n. 3
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);
            }
        }