Monday, October 13, 2008

DTO's from XSD's

Something I found out today. The xsd.exe from the VS command prompt can create your c# XML representations for you. Its lightening fast and means you can use code like this to get you XML to a CLR type:
MessageBase messageLoader = xmlSerializer.Deserialize(new StringReader(messageDocument.InnerXml)) as MessageBase;

Where MessageBase is my base abstract message class (this is obviously for getting XML messages off a queue). Of course this casting works with interfaces too.

Awesome! Thanks to Jamie for the heads up :)

1 comment:

Colin Scott said...

You could also try WSCF which is used on my current project. Now if only VS 2008 had an XSD editor...