.NET 2.0 Polymorphic Configuration properties?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
Back
Top