PC Review


Reply
Thread Tools Rate Thread

Customize DataContractSerializer to use class name as tag nameinstead of base class name + type attribute

 
 
Achim Domma
Guest
Posts: n/a
 
      14th Aug 2008
Hi,

in my data contract I have a member like this:

[DataMember]
public List<BaseClass> Items { get { ... } }

The property is serialized as a list of <BaseClass> tags with an
i:type attribute. It would be better for me to have <DerivedClass>
tags for the different subclasses. Is there a way to enforce that?

Achim
 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      14th Aug 2008
I think that is just how DataContractSerializer works. IIRC, you have
more control in XmlSerializer via XmlArrayItem.

Marc
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). murl Microsoft ASP .NET 0 27th Mar 2007 10:30 PM
Casting a C# base class object to a derived class type. =?Utf-8?B?Q2hyaXMgQ2Fwb24=?= Microsoft C# .NET 5 3rd Jun 2005 11:35 PM
Base class property Attribute not applied to derived class propert =?Utf-8?B?RGF2aWQgTA==?= Microsoft Dot NET Framework 0 9th Mar 2005 08:53 PM
Getting type of inheriting class from static methods in base class /kim/birkelund/aka/sekhmet Microsoft Dot NET 4 30th Mar 2004 12:39 PM
variable type that can be declared in a base class this is accessible only to classes that inherit the base class Dan Microsoft ASP .NET 1 24th Mar 2004 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:01 AM.