Solved

Object Cloning using MVVMLight

Posted on 2011-03-01
5
401 Views
Last Modified: 2012-06-27
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
Comment
Question by:dineshwins
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 35007565
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
 

Author Comment

by:dineshwins
ID: 35024236
@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
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 35027051
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
 

Accepted Solution

by:
dineshwins earned 0 total points
ID: 35125641
I have solved this issue by creating an extension method for making clones of the entities using serialization.
0
 

Author Closing Comment

by:dineshwins
ID: 35163591
Nobody was able to provide me with the required solution. I did my RnD & found a solution to the problem.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now