Ok I'm playing with some Silverlight and with WCF. And while if you stick with the standard stuff it works great, but if you want something special you get trouble. And I wanted DUPLEX communication. Ok more on that in a later blog.
Here is some cool code I used to Serialize/Deserialize some off the communication I'm doing between Silverlight and WCF.
private T Read<T>(string value)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
return (T) serializer.Deserialize(new StringReader(value));
}
private string Write<T>(T value)
{
StringWriter writer = new StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(writer, value);
return writer.ToString();
}
It uses generics, introduced in .NET Framework 2.0. Let me know if you can use it.