jeudi 4 août 2016

How to Use Reflection to Check Method Body Classes and Properties?

I'm trying to write an app that returns all the error codes of all methods used in the application.

Simply put, given MethodInfo of the below method, how to use Reflection to find out whether Method1 returns a class with Status, Code and Message Properties. How to find out what values these properties contain?

public void Method1()
{
 var response = new Class1()
 {
   Status = Status.Failed,
   Details = new StatusDetails()
   {
     Code = AllCodes.Code1,
     Message = AllMessages.Message1
   }
 }

 return response;
}

MethodInfo mi = typeof(Example).GetMethod("Method1");
MethodBody mb = mi.GetMethodBody();
// how?!





Aucun commentaire:

Enregistrer un commentaire