Deep Copy using Reflection in an Extension Method for Silverlight?

Posted by didibus on Stack Overflow See other posts from Stack Overflow or by didibus
Published on 2012-11-02T15:48:19Z Indexed on 2012/11/02 17:03 UTC
Read the original article Hit count: 196

So I'm trying to find a generic extension method that creates a deep copy of an object using reflection, that would work in Silverlight. Deep copy using serialization is not so great in Silverlight, since it runs in partial trust and the BinaryFormatter does not exist. I also know that reflection would be faster then serialization for cloning.

It would be nice to have a method that works to copy public, private and protected fields, and is recursive so that it can copy objects in objects, and that would also be able to handle collections, arrays, etc.

I have searched online, and can only find shallow copy implementations using reflection. I don't understand why, since you can just use MemberwiseClone, so to me, those implementations are useless.

Thank You.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Silverlight