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