Paste XML as serializable type

I had the privilege to see Steve Maine do some coding in a Microsoft SDR session after MIX07.While coding, he showed this cool tool that’s in the BizTalk Services SDK. He was showing something he had build and copied a bit of XML into the clipboard and used this tool inside Visual Studio 2005 to paste it as a serializable type, converted from the blob of XML.

The tool just used the XML to create the new class. Easy as that, but really useful! It’s in the menu under “Edit”, and then “Paste XML as Serializable Type”. I haven’t stress tested it yet, as it’s late when I’m writing this and I’m still very tired from missing so many hours of sleep during MIX07.Don’t ask what I’ve spend them on; What happens in Vegas, stays in Vegas! 😉

  WCF   MIC

 Take the XML above and have a look at the class below.

[System.Xml.Serialization.XmlRootAttribute(Namespace = “”, ElementName = “training”)] public class TrainingClass {   private string nameField;   private string locationField;   [System.Xml.Serialization.XmlElementAttribute(Namespace = “”, ElementName = “name”)]   public virtual string Name   {     get { return this.nameField; }     set  {  this.nameField = value;  }   }   [System.Xml.Serialization.XmlElementAttribute(Namespace = “”, ElementName = “location”)]   public virtual string Location   {     get { return this.locationField;}     set { this.locationField = value;}   }  }

It’s located in the BizTalk Services SDK. Once installed, it’s under C:Program FilesBizTalk Services SDKSamplesWebTooling. Usable in both Visual Studio 2005 and “Orcas”. Everyone immediately responded that they wanted the tool in a PowerTools package or something. It might be released that way, but until then download the SDK. And don’t let the BizTalk name fool you, this tool and the services in the SDK are really useful. I hope to write about it a bit more.