clone

How can you clone a WPF object?

Anybody have a good example how to deep clone a WPF object, preserving databindings? The marked answer is the first part. The second part is that you have to create an ExpressionConverter and inject it into the serialization process. Details for this are here: http://www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx?fid=1428301&a...

How do I clone a generic List in Java?

I have an ArrayList<String> that I'd like to return a copy of. The ArrayList clone method has the following signature: public Object clone() After I call this method, how do I cast the returned Object back to a ArrayList<String>? ...

Creating objects driven by the database to populate a Treeview - very slow

I have an application that reads a table from a database. I issue an SQL query to get a result set, based on a unique string value I glean from the results, I use a case/switch statement to generate certain objects (they inherit TreeNode BTW). These created objects get shunted into a Dictionary object to be used later. Whilst generat...

How do you make a deep copy of an object in Java?

In java it's a bit difficult to implement a deep object copy function. What steps you take to ensure the original object and the cloned one share no reference? ...

Cloning objects in C#

I want to do something like... myObject myObj = GetmyObj()//create and fill a new object myObject newObj = myObj.Clone(); ...and then make changes to the new object that are not reflected in the original object. I don't often need this functionality so when it's been necessary I've resorted to creating a new object and then copying e...

What is the most efficient way to clone a JavaScript object?

What is the most efficient way to clone a JavaScript object? I've seen: obj = eval(uneval(o)); but that's not cross platform (FF only). I've done (in Mootools 1.2) things like this: obj = JSON.decode(JSON.encode(o)); but question the efficiency. I've also seen recursive copying function, etc. I'm pretty surprised that out-of-the-bo...

What is the best way to clone/deep copy a .NET generic Dictionary<string, T>?

I've got a generic dictionary Dictionary that I would like to essentially make a Clone() of ..any suggestions. ...

Is dd better than cat?

Suppose I want to clone my hard drive (hda) to another drive (hdb) in the same computer. As I see it, there's two easy, rough and do-it-yourself ways: cat /dev/hda > /dev/hdb and dd if=/dev/hda of=/dev/hdb What technical reasons are there to that the latter is often/always said to be better than the former? under no circumstances tr...

Creating a new rrd database based on an existing one

I have some old rrdtool databases, for which the exact creation recipe has long been since lost. I need to create a new database with the same characteristics as the current ones. I've dumped a couple of old databases and pored over the contents but I'm not sure how to interpret the metadata. I think it appears in the following stanzas ...

Can clone VM be application backup plan?

Hi, I am application developer and don't know much about virtual machine(VM). however, our application is resided on a VM. frequent patch need be apply to fix/update this application. For diaster recovery, It was suggest to backup every thing on the server. so, once server is restored, no application need be re-installed and configured....

How do I create a copy of an object in PHP?

It appears that in PHP objects are passed by reference. Even assignment operators do not appear to be creating a copy of the Object. Here's a simple, contrived proof: <?php class A { public $b; } function set_b($obj) { $obj->b = "after"; } $a = new A(); $a->b = "before"; $c = $a; //i would especially expect this to create a cop...

What is the best way to clone a business object in Silverlight?

What is the best way to create a clone of a DTO? There is not an ICloneable interface or a BinaryFormatter class in Silverlight. Is reflection the only way? ...

Cloning Objects in VBA?

Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer? Dim x As New Class1 Dim y As Class1 x.Color = 1 x.Height = 1 Set y = x y.Color = 2 Debug.Print "x.Color=" & x.Color & ", x.Height=" & x.Height By generic i mean something like Set y = CloneObject(x) rather ...

How do I clone a generic list in C#?

I have a generic list of objects in C#, and wish to clone the list. The items within the list are cloneable, but there doesn't seem to be an option to do list.Clone() Is there an easy way around this? ...

Mandatory cloneable interface in Java

Hi everybody, I'm having a small problem in Java. I have an interface called Modifiable. Objects implementing this interface are Modifiable. I also have a ModifyCommand class (with the Command pattern) that receive two Modifiable objects (to swap them in a list further on - that's not my question, I designed that solution already). Th...

How to set up GRUB in a cloned hard disk

My PC has a hard disk at /dev/hda and boots from its MBR using the GRUB bootloader. I connected a second hard disk at /dev/hdc, formatted it and copied to it all files from my original hard disk. Now I want to make the second hard disk bootable, when it is connected as the primary hard disk (i.e. as /dev/hda). (The second hard disk has ...

C# Reflection Indexed Properties

I am writing a Clone method using reflection. How do I detect that a property is an indexed property using reflection? For example: public string[] Items { get; set; } My method so far: public static T Clone<T>(T from, List<string> propertiesToIgnore) where T : new() { T to = new T(); Type myType = from...

How does PHP5 'clone' work?

Edit: This behaviour is reproducible with query globals on. I have the following: $_SESSION['query_key'] = $_GET['query_key']; print($query_key); Vs. $_SESSION['query_key'] = clone $_GET['query_key']; print($query_key); The former prints out the value of $query_key, while the latter prints nothing. What sort of weird side ...

How to clone a jQuery Listen plugin event?

I have some <tr> elements on my page with a click() event attached to an image that sits inside each one. I use this code $(this).clone(true).appendTo("table#foo"); to do the following: copy those <tr>s into a different table preserve the click events on the images inside the <tr>s (because of the true argument) All of that works ...

Migrate Software Deployed on Linux VM?

I've got some software I created deployed on a Linux VM. I'd like to deploy a second copy of the software on a second virtual machine. Ideally, I'd like to just clone the VM volume, fire up a second copy, change the IP address, and that's that. It there anything else to it, or is it really just that simple. ...