Sample code I use in http://chamixblog.azurewebsites.net.