This project has moved. For the latest updates, please go here.

DynamicDeepCopy

Topics: User Forum
Dec 27, 2006 at 5:19 AM
I'm working on a project right now that has me writing an object mapper using Emit to generate bulk methods for getting and setting designated members to map from one class to another. One of the things that may come out of it is a DynamicDeepCopy for adding DeepCopy to a type. If I ever build it, would you be interesting in incorporating it into your library?

Thanks
-jason
Coordinator
Dec 27, 2006 at 8:08 AM
I would definately be interested. If the quality of code is good, I will add you to the project as a contributor if you like. Send me the goods at IDisposable@gmail.com

One question, how will this differ from simply doing a serialize/deserialize (which does a deep copy with related objects)?

FYI, I'm going to be commiting a couple things in this project again as soon as a minor issue with the CodePlex workspaces and my old (deceased) laptop is resolved.
Dec 27, 2006 at 3:47 PM
Honestly, I don't know how much it would differ from Serialization. The idea doesn't really come out of a specific need, I will just have most of the code done (via the bulk method calls), so it seemed like a good next step. I have had a need in the past for deep copy support though. I would think it would be faster than serialization and it would not require you to mark up your objects as serializable.

The downside to the bulk calls is that right now they take object[] for the properties to be set and return an object[] for retrieved properties (I can't have them both in one method because I am tranforming from one class to another) so there will usually be boxing/unboxing. The only alternative I could come up with was to include Generic Delegates for up to n parameters, but since an object could have dozens of properties, this didn't seem like a very clean approach either.

As long as I'm deep copying an object tree, however, the getting and setting should be able to be called from within the same method on each object and should, I would think, be very fast as there is no serialization / deserialization happening.

That's about all I can come up with though. Any thoughts?