- /// public class Pig
- /// {
- /// [XmlElement]
- /// public string Name = "piglet"
- /// }
- ///
- /// public class Cow
- /// {
- /// [XmlAttribute]
- /// public string Name = "daisy"
- /// }
- ///
- /// public class Farm
- /// {
- /// [DictionaryElementType(typeof(Pig), "pig")]
- /// [DictionaryElementType(typeof(Cow), "cow")]
- /// public IDictionary Animals;
- ///
- /// public Farm()
- /// {
- /// IDictionary dictionary = new Hashtable();
- /// dictionary["Piglet"] = new Pig();
- /// dictionary["Daisy"] = new Cow();
- /// }
- /// }
- ///
- ///
- /// Serialized output of Farm:
- ///
- ///
- ///
- ///
- /// piglet
- ///
- ///
- ///
- ///
- /// If only one DictionaryElementAttribute is present, the dictionary is assumed to only
- /// contain the type specified by that attribute. The typealias is therefore not needed
- /// and will be omitted from the serialized output.
- /// - /// You need to mark any IList field or property to be serialized with this attribute - /// at least once. The attribute is used to map an element name to the type - /// of object contained in the list. - ///
- ///