.NET 2.0 Polymorphic Configuration properties?

G

Guest

Given:
class AnimalElement : ConfigurationElement
class Dog: AnimalElement { ... }
class Cat: AnimalElement {...}

class MyElement : ConfigurationElement
{
private const string animalProperty = "animal";

[ConfigurationProperty(animalProperty, IsRequired=true)]
public AnimalElement Animal
{
get { return (AnimalElement)base[animalProperty]; }
set { base[animalProperty] = value; }
}
}

If Cat and Dog deinfe additional configuration properties, when I
deserialize the config element, I'll get a ConfigurationErrorsException :
"Unrecognized attribute..." for those additional attributes.

I thouhgt I could put an attribute on my Animal property the same way
XmlInclude used to work in .NET 1.1 but can`t find something similar.

Is there a way to have polymorphic Configuration elements?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top