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