HighTechTalks DotNet Forums  

Serialze only base informatio of derived class

Dotnet XML microsoft.public.dotnet.xml


Discuss Serialze only base informatio of derived class in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jerad Rose
 
Posts: n/a

Default Serialze only base informatio of derived class - 12-03-2007 , 04:38 PM






I have two classes:

public class BaseClass { ... }
public class DerivedClass : BaseClass { ... }

Suppose I have the following code:

DerivedClass dc = new DerivedClass();
BaseClass bc = (BaseClass)dc;

How can I serialize "bc" so that only the members of BaseClass are
serialized? Currently, it is doing this:

<BaseClass xsi:type="DerivedClass">
//DerivedClass members (including BaseClass members)
</BaseClass>

When what I want is this:

<BaseClass>
//BaseClass members only
</BaseClass>

Is this possible? If so, and you need more info in order to help further,
let me know what you need. I would prefer to be able to do this without
having to explicitly control the entire serialization process. But if
that's my only option, I may go about this a different way.

Thanks in advance.

Jerad



Reply With Quote
  #2  
Old   
Jerad Rose
 
Posts: n/a

Default Re: Serialze only base informatio of derived class - 12-06-2007 , 08:16 AM






I am reposting this on microsoft.public.dotnet.general. Please respond to
that thread if you have any suggestions.

Thanks.
Jerad

"Jerad Rose" <no (AT) spam (DOT) com> wrote

Quote:
I have two classes:

public class BaseClass { ... }
public class DerivedClass : BaseClass { ... }

Suppose I have the following code:

DerivedClass dc = new DerivedClass();
BaseClass bc = (BaseClass)dc;

How can I serialize "bc" so that only the members of BaseClass are
serialized? Currently, it is doing this:

BaseClass xsi:type="DerivedClass"
//DerivedClass members (including BaseClass members)
/BaseClass

When what I want is this:

BaseClass
//BaseClass members only
/BaseClass

Is this possible? If so, and you need more info in order to help further,
let me know what you need. I would prefer to be able to do this without
having to explicitly control the entire serialization process. But if
that's my only option, I may go about this a different way.

Thanks in advance.

Jerad





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.