Solved

Object Cloning using MVVMLight

Posted on 2011-03-01
5
406 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 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

691 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