DataContract is the default serialization programming model for WCF. However WCF supports more than just the types marked wth DataContract attribute. It supports serialization of the following kinds of types in the default mode.
- CLR built-in types
- Byte array, DateTime, TimeSpan, GUID, Uri, XmlQualifiedName, XmlElement and XmlNode array [This includes XElement and XNode array from .NET 3.5]
- Types marked with DataContract or CollectionDataContract attribute
- Types that implement IXmlSerializable
- Arrays and Collection classes including List<T>, Dictionary<K,V> and Hashtable.
- Types marked with Serializable attribute including those that implement ISerializable.
- Types with none of the above attributes (POCO) but with a default constructor (can be non-public). [This is supported only from .NET 3.5 SP1]
Here is a DataContract class that no one will ever see in real world. Figuring out which programming model is implemented by these types is left as an exercise to the readers.
public class ComplexDataContract