Ejemplo n.º 1
0
 public void TestInvokeCtorViaConstructorInfo()
 {
     RunWith(type => {
         ConstructorInfo ctorInfo = type.Constructor(typeof(string), typeof(int));
         object person            = ctorInfo.CreateInstance(null, 10).WrapIfValueType();
         VerifyFields(person, new { name = (string)null, age = 10 });
     });
 }
Ejemplo n.º 2
0
 public static object CreateInstanceSafe(this ConstructorInfo ctor)
 {
     try
     {
         return(ctor.CreateInstance());
     }
     catch (TargetInvocationException)
     {
         return(null);
     }
 }