Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Object Cloning using MVVMLight

Posted on 2011-03-01
5
Medium Priority
?
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 41

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 41

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Make the most of your online learning experience.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Six Sigma Control Plans

618 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