Exemplo n.º 1
0
 static void Main(string[] args)
 {
   Object o = new TestCase();
   MethodInfo method = o.GetType().GetMethod("test");
   Object result = method.Invoke(o, new object[0]);
   WrappedMessageList list = new WrappedMessageList(result);
   for (int i = 0; i < list.getCount(); ++i)
   {
     Message curr = list.getMessage(i);
     Console.WriteLine(curr.Msg);
   }
 }
Exemplo n.º 2
0
    public  WrappedMessageList Invoker(Type type)
    {
      object testObj = Activator.CreateInstance(type);
      Type created = testObj.GetType();
      object[] args = new object[0];
      bool TestExecuted = false;
      List<string> ret1 = new List<string>();
      WrappedMessageList ret = null;

      //id = (string)created.InvokeMember(
      //  /* method name */ "id",
      //  /* action      */ BindingFlags.Default | BindingFlags.InvokeMethod,
      //  /* binder      */ null,
      //  /* instance    */ testObj,
      //  /* method args */ args
      //);


      // test may throw so prepare for that exception

      //TestExecuted = (bool)created.InvokeMember(
      //  /* method name */ "Test",
      //  /* action      */ BindingFlags.Default | BindingFlags.InvokeMethod,
      //  /* binder      */ null,
      //  /* instance    */ testObj,
      //  /* method args */ args
      //);
      Object result = created.InvokeMember(
        /* method name */ "test",
        /* action      */ BindingFlags.Default | BindingFlags.InvokeMethod,
        /* binder      */ null,
        /* instance    */ testObj,
        /* method args */ args
   );

      if (result != null)
      //  ret1 = (List<string>)created.InvokeMember(
      //    /* method name */ "GetMessage",
      //    /* action      */ BindingFlags.Default | BindingFlags.InvokeMethod,
      //    /* binder      */ null,
      //    /* instance    */ testObj,
      //    /* method args */ args
      //);
      {
        ret = new WrappedMessageList(result);
      }

     // ret = ConvertStringToMessage(ret1, type);

      return ret;
    }