I have just started WCF. I had a question with respect to serialization. I know WCF uses DataContract Serialization by default behind the scenes. I have looked at some code online by Aaron Skonnard in his article http://msdn.microsoft.com/en-us/magazine/cc163569.aspx. The code below is from his article. In this he has written code to serialize a Person object. My question is doesn't WCF do this behind the scenes. Why do we have to write the serialization logic? and then de-serialize it back again. As a WCF starter I am confused as to when to write this code and when not to. I think this would just work fine if there were no serialization logic written. Help appreciated!
static void WriterPersonSerializable()
{
Person p = new Person("Bob", 34, "secret");
p.spouse = new Person("Jane", 33, "secret");
using (FileStream fs = new FileStream("person.xml", FileMode.Create))
using (XmlDictionaryWriter writer =
XmlDictionaryWriter.CreateTextWriter(fs))
{
DataContractSerializer serializer =
new DataContractSerializer(typeof(Person));
serializer.WriteObject(writer, p);
}