Posts

Showing posts from 2006

IList Serialization with XmlSerializer. Good thing to know.

Serialization with XmlAttribute is quite useful. However, when serializing a sequence (IList for instance) you have to be careful. If you use a public property to expose the IList member to serialize, don't waste time on the Set{} method, it will not be called by the deserializer, at least for the XmlSerializer. The Set{} is simply not use by the XmlSerializer.Deserialise method. private IList recipients = new System.Collections.ArrayList(); public IList Recipients { get{return this.recipients;} set { throw new ApplicationException("Use the get method instead and work with IList.Add method. This is what XmlSerializer.Deserialise does!"); } }