Can someone tell me how can i ask if a certain variable inside a method 
inhertis class X?

View class is "TypeDefinition"

-------------------------------------------

TypeDefinition viewClass = "";

Collection<TypeDefinition> types = assembly.Types;

if (types != null && types.Any())
{
    foreach (TypeDefinition type in types)
    {
        Collection<MethodDefinition> methods = type.Methods; // 
GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | 
BindingFlags.Public);

        if (methods != null && methods.Any())
        {
            foreach (MethodDefinition method in methods)
            {
                Mono.Cecil.Cil.MethodBody methodBody = method.Body;

                if (methodBody != null &&
                    methodBody.Variables != null &&
                    methodBody.Variables.Any())
                {
                    foreach (VariableDefinition variable in 
methodBody.Variables)
                    {
                        TypeReference variableType = variable.VariableType;

                        if (variableType != null)
                        {
                            //bool isSubClass = 
variableType.base(viewClass);

                            //if (isSubClass) 
                            //{
                            //    MethodInfo[] methodInfo = 
variableType.GetMethods();

                            //    if (methodInfo != null && 
methodInfo.Any())
                            //    {
                            //        views.Add(new ViewObject { View = 
variableType, Methods = methodInfo });
                            //    }
                            //}
                        }
                    }
                }
            }
        }
    }
}

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mono-cecil+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to