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