A set of C# extension methods and helper code