private void Add(T item, CollectionStates state) { if (item is INotifyPropertyChanged notifiableItem) { notifiableItem.PropertyChanged += item_PropertyChanged; } _internalCollection.Add(item, state); }
private bool ChangeState(T item, CollectionStates state) { var fod = _internalCollection.ContainsKey(item); if (!fod) { return(false); } _internalCollection[item] = state; return(true); }
private bool AttachTransactionIfSet(TEntity changedItem, CollectionStates action) { if (Transaction.Current != null) { if (_currentTransaction == null) { _currentTransaction = Transaction.Current; _currentTransaction.TransactionCompleted += _currentTransaction_TransactionCompleted; } var hasElement = _transactionalItems.FirstOrDefault(s => s.Item.Equals(changedItem)); if (hasElement != null) { if (hasElement.State == CollectionStates.Added) { if (action == CollectionStates.Removed) { _transactionalItems.Remove(hasElement); } } if (hasElement.State == CollectionStates.Removed) { if (action == CollectionStates.Added) { hasElement.State = CollectionStates.Unchanged; } } } else { _transactionalItems.Add(new TransactionalItem <TEntity>(changedItem, action)); } return(true); } return(false); }
private void Add(T value, CollectionStates state) { value.PropertyChanged += item_PropertyChanged; _internalCollection.Add(value, state); }
internal TransactionalItem(TEntity item, CollectionStates state) { Item = item; State = state; }