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