Inheritance: TreeNode
Ejemplo n.º 1
0
 public static MethodNode CreateNode(MethodDefinition definition)
 {
     string methodName = GetMethodName(definition);
     var node = new MethodNode(definition, methodName);
     ProcessDefinition(node, definition);
     return node;
 }
Ejemplo n.º 2
0
        private static void ProcessDefinition(MethodNode node, MethodDefinition definition)
        {
            if (!definition.HasBody)
            {
                return;
            }

            foreach (Instruction instruction in definition.Body.Instructions)
            {
                if (instruction.OpCode == OpCodes.Call
                    || instruction.OpCode == OpCodes.Callvirt
                    || instruction.OpCode == OpCodes.Calli)
                {
                    var operandNS = (instruction.Operand as MemberReference).DeclaringType.Namespace;

                    if (ioNamespaces.Any(ns => operandNS.StartsWith(ns)))
                    {
                        node.IOIcon = Resources.file;
                    }
                    else if (netNamespaces.Any(ns => operandNS.StartsWith(ns)))
                    {
                        node.NetIcon = Resources.network;
                    }
                    else if (securityNamespaces.Any(ns => operandNS.StartsWith(ns)))
                    {
                        node.SecurityIcon = Resources.security;
                    }
                }
            }
        }