J
jjkboswell
I have an XSD which I have generated a class from using the xsd.exe
tool. My XSD contains complex types within it, so that the generated
class has member variables which are of types that are also defined in
the XSD.
I deserialize XML data into instances of that class, and serialize back
to XML. So far so good.
However, in my code I have the concept of wanting to create new copies
of these deserialized objects and modifying some of the members of the
new copies. This obviously presents a problem because I don't want the
member variables referencing the same data.
In other words I *think* I want to do a deep copy, but everything I've
read on "C# copy constructors and ICloneable" seems to point to this
area being a route to no-where. Besides which, my generated classes
don't support ICloneable and I can't keep writing my own copy
constructors each time I generate the class.
So... is there a design pattern for this model that can help me
overcome these problems? It seems that I could make use of
serialization to create new copies, which is handy because my generated
classes, by nature, support serialization.
Any advice or references on "the right thing to do" would be much
appreciated.
Boz
tool. My XSD contains complex types within it, so that the generated
class has member variables which are of types that are also defined in
the XSD.
I deserialize XML data into instances of that class, and serialize back
to XML. So far so good.
However, in my code I have the concept of wanting to create new copies
of these deserialized objects and modifying some of the members of the
new copies. This obviously presents a problem because I don't want the
member variables referencing the same data.
In other words I *think* I want to do a deep copy, but everything I've
read on "C# copy constructors and ICloneable" seems to point to this
area being a route to no-where. Besides which, my generated classes
don't support ICloneable and I can't keep writing my own copy
constructors each time I generate the class.
So... is there a design pattern for this model that can help me
overcome these problems? It seems that I could make use of
serialization to create new copies, which is handy because my generated
classes, by nature, support serialization.
Any advice or references on "the right thing to do" would be much
appreciated.
Boz