(http://csharppad.com/gist/10113200)