Radical Documentation
View on GitHub
release-1
release-1
  • Home
  • Presentation
    • AbstractViewModel
    • Conventions
      • Bootstrap Conventions
      • Runtime Conventions
      • Conventions override
    • Commands and DelegateCommand
    • IViewResolver
      • Default view behaviors
      • view life cycle events
        • Callback expectations
        • notify messages
    • Message broker MVVM built-in messages
    • Application boot process demystified
      • Application shutdown
      • Singleton applications
    • AbstractMementoViewModel
      • Simple ViewModel graphs
      • Collections and complex ViewModel graphs
    • Validation and Validation Services
  • UI Composition
    • UI Composition
      • Region content lifecycle
      • TabControl region
      • Create a custom region
  • Concepts
    • Inversion of Control
      • Castle Windsor
      • Autofac
      • Unity (v2 & v3)
      • Puzzle Container
    • Entities
      • Property System
    • Messaging and Message Broker
      • POCO messages
      • Standalone message handlers
    • Observers
      • PropertyObserver
      • MementoObserver
      • BrokerObserver
  • Memento
    • Change Tracking Service
      • MementoEntity and MementoEntityCollection
      • Handling change tracking:
        • Simple model
        • Collections
        • Complex objects graph
      • Atomic operations
      • Change Tracking Service API
      • Property Metadata for the ChangeTrackingService
      • Handling collection sync
  • Behaviors
    • DataGrid Behaviors
    • Password
    • Generic routed event handler to command behavior
    • Overlay adorner
      • Busy status manager
    • TextBox behaviors:
      • Command
      • Auto select
      • DisableUndoManager
  • Markup Extensions
    • Editor binding
    • Auto Command binding
  • How to
    • Get the view of a given view model
    • Bi-directional communication between different windows/views
    • Handle the busy status during async/long running operations
    • Implement a customer improvement program
    • Manage focus
    • Create a splash screen
    • Access view model after view is closed
    • Intercept ViewModels before it's used
Powered by GitBook
On this page
  1. Memento

Change Tracking Service

Dealing with complex graphs of objects can be complicated and can get more complicated as the graph evolve or gets huge.

Let us start from the end of the story, what we want to achieve in our software solutions is something like the following sample code:

var person = new Person();
person.FirstName = "first name value";
person.LastName = "last name value";

var address =  new Address();
address.Street = "street address value";

person.Addresses.Add( address );

Given the above code snippet we have basically 2 requirements:

  • Know the state of the graph:

    • Is it changed?

    • Is there something that can be undone?

    • Is there something that can be redone?

  • Change the state of the graph:

    • Accept all changes at once;

    • Reject all changes at once;

    • Undo a single change;

    • Redo a single change;

But there is more, from the user perspective a single change can be reflected in more than one action, and thus change, in the code itself:

var order = new Order();
order.Customer = ... //reference to a customer object;

// --> begin of "atomic" operation
var item = new OrderItem();
item.ItemId =  123;
item.Quantity = 2;
order.Items.Add( item );
// --> end of "atomic" operation

In the above sample the creation of the order item, the set of its properties and the add to the items collection, from the user perspective, are a single operation that matches the add to cart operation, given this assumptions an undo operation should rollback the entire change set and only the last operation, the add in this case.

PreviousBrokerObserverNextMementoEntity and MementoEntityCollection

Last updated 5 years ago

Given these requirements the next step is to rely on something that allows us to transparently handle the entire change tracking process, the first step is to understand what are.

MementoEntity and MementoEntityCollection