views:

39

answers:

1

I am trying to build a rest service that will return some data that is a collection of an abstract class which contains various implementation classes.

How do i set up my REST return type to be able to specify the various types that will be returned.

for instance.

<RootType>
 <dataAttribute></dataAttribute>
<Array>
  <ItemofClassA></ItemOfClassA>
  <ItemofClassB></ItemOfClassB>
  <ItemofClassC></ItemOfClassC>
</Array>
</RootType>

I belive i Will need something like this in my definition.

class RootType{

[XMLType (Typeof(ClassA)]
[XMLType (Typeof(ClassB)]
[XMLType (Typeof(ClassC)]
public AbstractClass[] Array{get;set;}

}
A: 

Maybe check How can I use polymorphism in XML Serialization for a hint.

Cheeso