Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Editable&lt;TWrappedObject&gt;"/> class.
 /// </summary>
 /// <param name="current">The current.</param>
 public Editable(TWrappedObject current)
 {
     _changedProperties = new Dictionary <PropertyInfo, object>();
     _current           = current;
     _metaData          = TypeMetaDataRepository.GetFor(GetType(), typeof(TWrappedObject));
     _reset             = new EditableCommand(ignored => UndoChanges(), ignored => true);
 }
        public EditableSet(ObservableCollection <TElement> originals, Action <TElement> editItemAction, Action <TElement> addItemAction, Action <TElement> deleteItemAction)
        {
            OriginalItems     = originals;
            _deleteItemAction = deleteItemAction;
            _addItemAction    = addItemAction;
            _editItemAction   = editItemAction;

            _inserted = new ObservableCollection <Editable <TElement> >();
            _editableOriginals.AddRange(OriginalItems.Select(orig => new Editable <TElement>(orig)));
            _allItems = new ObservableCollection <Editable <TElement> >(_editableOriginals);
            _allItems.CollectionChanged += CollectionChangedMethod;

            _undoItemChangesCommand = new EditableCommand <Editable <TElement> >(
                UndoItemChanges,
                item => item.HasChanges
                );
            _deleteItemCommand = new EditableCommand <Editable <TElement> >(
                DeleteItem,
                item => true
                );
            _undoChangesCommand   = new EditableCommand(ignored => UndoChanges(), ignored => true);
            _commitChangesCommand = new EditableCommand(ignored => CommitChanges(), ignored => true);
        }