示例#1
0
        /// <inheritdoc />
        public void Add(T item)
        {
            var removedItem = Removed.FirstOrDefault(c => object.Equals(c.Item, item));

            if (removedItem != null)
            {
                // Adding an item that was removed.
                Removed.Remove(removedItem);
                removedItem.Item   = item;
                removedItem.Action = ChangeAction.None;
                Items.Insert(removedItem.Index, removedItem);
            }
            else
            {
                Items.Add(new ChangeContainerItemWithIndex <T>(item, ChangeTarget.Collection, Items.Count, ChangeAction.Add));
            }
        }