jalvin

How do I do a deep copy of xmlreader in c#

I want to assign an xmlreader which is supplied to the constructor to a member variable.Thanks.

jack




Re: Visual C# General XmlReader and deep copy

Peter Ritchie

Unfortunately, I don't think it's possible. XmlReader is abstract and is not attributed as Serializable. The framework classes that implement XmlReader aren't public so you can't get at the state data.






Re: Visual C# General XmlReader and deep copy

jalvin

Then how do I achieve what i have set out to

Thanks Peter






Re: Visual C# General XmlReader and deep copy

Peter Ritchie

You'll have to know how the original XmlReader object was created (via URI, Stream, etc.) and create a new one in the same way.






Re: Visual C# General XmlReader and deep copy

jalvin

How do i know that

Only thing i know is that i am newed up and given an xmlreader.






Re: Visual C# General XmlReader and deep copy

Peter Ritchie

Then you don't have enough information to do what you want to do. If you have a method, for example, that accepts an XmlReader parameter you don't have enough information to make a deep copy of it. Your method would have to accept a Stream or a URI string in order to do what you want.