Well I think it's funny - .NET Edition

.NET Pickup Lines via K. Scott Allen

If I were a generic collection, I'd be strongly typed for you.

You must be the latest version, because I've been checking you out.

I have a small problem. I put an object in a Dictionary, but I lost the key! Can you come back to my place and help me look for it?

A TypeConverter just returned my heart, and it's ready to assign to you.

Let's turn off option strict and do some late night binding.

So, what's your hash code?

And some of my own:

The moment I saw you I knew my singleton days were over.

There is nothing IDisposable about my love for you.

I've been reflecting on your Attributes and I like what I see.

Oh dear.

Well I think it's funny

Made by the students of the Columbia Business School, this hilarious spoof "Every Change of Rate" features a man lamenting missing out on the Chairmanship of the Federal Reserve to the tune of "Every breath you take". Glenn Hubbard, Dean of the Columbia Business School, was rumored to be on the shortlist for the position which makes the whole thing even better. Here's a sample:

"First you move your lips

And hike a few more BiPS.

When demand then dips And the yield curve flips,

I'll be watching you."

Brilliant.

WebDialog 1.1 released

WebDialog 1.1 has been released.

Much improved support for Atlas is the primary feature of this WebDialog release.

What's New:

  • New Feature - Improved Atlas support in Internet Explorer and Opera.
  • Bug Fix - Fixed validators nested inside a dialog with client script enabled not displaying their error message when they failed.

Json.NET 1.1 released

Thanks again to the people that have tried out Json.NET and have reported bugs or offered suggestions. This release addresses all the issues that you've reported and that I'm aware of. 1.1 also adds a few new features.

  • New feature - XmlNodeConverter class provides a means to easy convert between Xml and JSON text. SerializeXmlNode and DeserializeXmlNode helper methods have also been added.
  • New feature - Handles parsing JavaScript constructor calls (i.e. new Date(1234)).
  • New feature - Improved date serializing and deserializing.
  • Change - Rewritten JavaScript string escape method.
  • Bug fix - Lots of little fixes to JsonSerializer.

Converting between XML and JSON

The big new feature added in Json.NET 1.1 is a converter class for XML. By using XmlNodeConverter (or the newly added helper methods) it is now extremely simple to convert JSON to XML and vice versa in .NET.

XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<?xml version=""1.0"" standalone=""no""?>
<root>
  <person id=""1"">
    <name>Alan</name>
    <url>http://www.google.com</url>
  </person>
  <person id=""2"">
    <name>Louis</name>
    <url>http://www.yahoo.com</url>
  </person>
</root>");
 
string jsonText = JavaScriptConvert.SerializeXmlNode(doc);
//{
//  "?xml": {
//    "@version": "1.0",
//    "@standalone": "no"
//  },
//  "root": {
//    "person": [
//      {
//        "@id": "1",
//        "name": "Alan",
//        "url": "http://www.google.com"
//      },
//      {
//        "@id": "2",
//        "name": "Louis",
//        "url": "http://www.yahoo.com"
//      }
//    ]
//  }
//}
 
XmlDocument newDoc = (XmlDocument)JavaScriptConvert.DeerializeXmlNode(jsonText);
 
Assert.AreEqual(doc.InnerXml, newDoc.InnerXml);

Elements, attributes, text, comments, character data, processing instructions, namespaces and the XML declaration are all preserved when converting between the two. The only caveat is that it is possible to lose the order of differently named nodes at the same level when they are grouped together into an array.

A Brief Guide

  • Elements remain unchanged.
  • Attributes are prefixed with an @.
  • Single child text nodes are a value directly against an element, otherwise they are accessed via #text.
  • The XML declaration and processing instructions are prefixed with ?.
  • Charater data, comments, whitespace and significate whitespace nodes are accessed via #cdata-section, #comment, #whitespace and #significate-whitespace respectively.
  • Multiple nodes with the same name at the same level are grouped together into an array.
  • Empty elements are null.

Json.NET 1.1 can be downloaded here.