GetTypeDefinition() public method

public GetTypeDefinition ( TypeReference type ) : Mono.Cecil.TypeDefinition
type Mono.Cecil.TypeReference
return Mono.Cecil.TypeDefinition
コード例 #1
0
        void GetVirtualMethods(AssemblyCache cache, HashSet <MethodKey> methods, TypeDefinition type)
        {
            // check the interfaces
            foreach (var ifaceRef in type.Interfaces)
            {
                TypeDefinition iface = project.GetTypeDefinition(ifaceRef.InterfaceType);

                // if it's not in the project, try to get it via the cache
                if (iface == null)
                {
                    iface = cache.GetTypeDefinition(ifaceRef.InterfaceType);
                }

                // search interface
                if (iface != null)
                {
                    GetVirtualMethods(cache, methods, iface);
                }
            }

            // check the base type unless it isn't in the project, or we don't have one
            TypeDefinition baseType = project.GetTypeDefinition(type.BaseType);

            // if it's not in the project, try to get it via the cache
            if (baseType == null)
            {
                baseType = cache.GetTypeDefinition(type.BaseType);
            }

            // search base
            if (baseType != null)
            {
                GetVirtualMethods(cache, methods, baseType);
            }

            foreach (MethodDefinition method in type.Methods)
            {
                if (method.IsVirtual)
                {
                    methods.Add(new MethodKey(method));
                }
            }
        }
コード例 #2
0
ファイル: InheritMap.cs プロジェクト: remobjects/Obfuscar
        void GetVirtualMethods(AssemblyCache cache, HashSet<MethodKey> methods, TypeDefinition type)
        {
            // check the interfaces
            foreach (TypeReference ifaceRef in type.Interfaces) {
                TypeDefinition iface = project.GetTypeDefinition (ifaceRef);

                // if it's not in the project, try to get it via the cache
                if (iface == null)
                    iface = cache.GetTypeDefinition (ifaceRef);

                // search interface
                if (iface != null)
                    GetVirtualMethods (cache, methods, iface);
            }

            // check the base type unless it isn't in the project, or we don't have one
            TypeDefinition baseType = project.GetTypeDefinition (type.BaseType);

            // if it's not in the project, try to get it via the cache
            if (baseType == null)
                baseType = cache.GetTypeDefinition (type.BaseType);

            // search base
            if (baseType != null)
                GetVirtualMethods (cache, methods, baseType);

            foreach (MethodDefinition method in type.Methods) {
                if (method.IsVirtual)
                    methods.Add (new MethodKey (method));
            }
        }