// [TestMethod] public void TestStatic() { dynamic a = new StaticMembersDynamicWrapper(typeof(B)); int i = (int)a.b; Contract.Assert(i == 6); }
//extend int public static dynamic TryParse <T>(this string input) { dynamic runner = new StaticMembersDynamicWrapper(typeof(T)); T value; bool isValid = runner.TryParse(input, out value); return(new { IsValid = isValid, Value = value }); }
private static void DynamicStaticInvocations() { dynamic staticType = new StaticMembersDynamicWrapper(typeof(StaticTestType)); Console.WriteLine(staticType.Method(5)); staticType.Field = DateTime.Now; Console.WriteLine(staticType.Field); staticType.Property = Guid.NewGuid(); Console.WriteLine(staticType.Property); }
//extend int public static dynamic TryParse <T>(this string input) { var instance = Activator.CreateInstance <T>(); dynamic runner = new StaticMembersDynamicWrapper(instance.GetType()); T value; bool isValid = runner.TryParse(input, out value); return(new { IsValid = isValid, Value = value }); }