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! 😉

<training>

  <name>WCF</name>

  <location>MIC</location>

</training>

 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.

Technorati tags: ,

You may also like...

3 Responses

  1. Hi Dennis! I’m very excited about this feature. However, I’m unable to install IE7 and .NET 3.0 here yet…

    Is there any way that you could grab just this addin and post or email me those bits? Would it even work in plain vanilla VS2005?

    As an aside, I’m doing a “tools” talk at our Philly.NET Code Camp tomorrow, and I’d *LOVE* to show off this thing 🙂

    Thanks!
    Travis

  2. Oh shit, totally forgot this one…

    I have installed BizTalk Services on my laptop and I think they can be installed seperately. If you mail me, I’ll send them.

    http://bloggingabout.net/blogs/dennis/contact.aspx

  3. DrakeNadia25 says:

    If you are in the corner and have no cash to get out from that point, you will have to receive the personal loans. Because that will help you unquestionably. I take auto loan every time I need and feel myself OK because of it.

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.