Transactional objects in .NET.

In user interfaces, it is often required to implement a cancel button when editing certain objects. In WPF, it would be nice if you could make your review model transactional. I will try to explain a little more about what I mean:

The view model is connected to the model and provides data so that it can be easily processed (using data binding). Changes in the presentation model lead to changes in the model. However, if there is a cancel button, you usually don’t want to immediately make changes to the model, so I’m thinking about some buffering changes. When you commit changes, they are transferred to the model, otherwise they are deleted.

Currently, I have implemented a solution that creates a proxy of a view model that is tied to a view instead of a real view model. The proxy is not connected to the model, but records changes in properties and method calls using interceptors. There is a dispatch method that applies calls in a real view model. I think this is a good solution, but it is still pretty bad (if the view model contains collections, etc.).

I am looking for a framework that does such things. Is there any?

Best regards,
Oliver Hanappi

+3
source share
3 answers

BindingGroups , BindingGroup BeginEdit, CommitEdit CancelEdit, . MVVM-, , - , , , .

+1

Cinch MVVM Framework Sacha Barber.

" IEditableObject / / "

+2

, , (). , . , , .

Other options include implementing IEditableObject to roll back changes: http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.aspx It's not always nice when you try to make deep copies of non-trivial objects.

I think your decision is fine, but I am curious why everything is getting bad with collections.

+1
source

Source: https://habr.com/ru/post/1729579/


All Articles