Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

Object Cloning using MVVMLight

We want to create a copy of the object being edited before making any changes to the objects. We are using MVVMLight with WPF. Kindly suggest some approaches to implement object cloning using MVVMLight.
0
dineshwins
Asked:
dineshwins
  • 3
  • 2
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
In your view model just make a backup of the object.

Dim backup as MyService.MyObject
Dim theObject as MyService.MyObject


Sub cmdEdit_Click
  backup = theobject
  edit = true
end sub

Sub RollBack
  theobject = backup
end sub
0
 
dineshwinsAuthor Commented:
@ged325: I assume the above will create a shallow copy whereas I require the Deep Copy of the object being edited so that at any stage user can revert back to the original values.
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
then instead of backup use clone.

backup = theobject.Clone()

theobject = backup.Clone()

http://silverlightarvind.blogspot.com/2010/05/c-shallow-copy-vs-deep-copy.html

0
 
dineshwinsAuthor Commented:
I have solved this issue by creating an extension method for making clones of the entities using serialization.
0
 
dineshwinsAuthor Commented:
Nobody was able to provide me with the required solution. I did my RnD & found a solution to the problem.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now