I want to know if is possible to get the method body via c# reflection and identify expressions, conditions, loops etc.
For example, assume I have a class,
class Employee
{
private int Number1{get;set;}
private int Number2{get;set;}
public int GetNumber()
{
if(Number1>0)
{
return Number1;
}
else if(Number2>0)
{
return Number2;
}
return Number1 + Number2;
}
}
So here if you see the above class is having a method with some conditions. In reflection I want to read the method body and identify these conditions. Like,
var methodBody = methodInfo.GetMethodBody();
methodBody.Condition?????
Aucun commentaire:
Enregistrer un commentaire