Exemplo n.º 1
0
        private bool FindInterfaceMethod(MethodDefinition method, MethodObject methodNode)
        {
            // multi level inheritance is flattened here
            foreach (var interfaceParent in method.DeclaringType.Interfaces)
            {
                var matchingMethod = InterfaceMethodsIndexedByTypeName.Get(interfaceParent.InterfaceType.FullName)
                                     .FirstOrDefault(x => SignatureKeyService.GetMethodSignature(x).Equals(SignatureKeyService.GetMethodSignature(method)));
                if (matchingMethod != null)
                {
                    methodNode.InterfaceMethod = matchingMethod;
                    methodNode.ImplementsType  = ImplementsType.Interface;

                    return(true);
                }
                else // might be an interface with generics. We have indexed the generic form but now search using a generic instance (instead of T, a real type)
                {
                    TypeDefinition interfaceDefinition = null;
                    var            resolved            = ResolveService.TryResolve(interfaceParent.InterfaceType, out interfaceDefinition);
                    if (resolved && interfaceDefinition.GenericParameters.Any())
                    {
                        return(ResolveGenericsInterface(method, methodNode, interfaceParent.InterfaceType, interfaceDefinition));
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private MethodNode GetMethodNode(GraphType graphType, string appDomain, MethodObject method)
        {
            var methodDef = method.GetMethodDefinition();

            var methodNode = new MethodNode(graphType, appDomain);

            methodNode.MethodName = SignatureKeyService.GetMethodSignature(methodDef);
            methodNode.IsPublic   = methodDef.IsPublic && methodDef.DeclaringType.IsPublic;

            if (method.HasImplementation())
            {
                methodNode.ConcreteType = new TypeInfo();
                methodNode.ConcreteType.AssemblyName    = method.ConcreteMethod.DeclaringType.Module.Assembly.Name.Name;
                methodNode.ConcreteType.AssemblyVersion = GetAssemblyVersion(method.ConcreteMethod);
                methodNode.ConcreteType.TypeName        = method.ConcreteMethod.DeclaringType.FullName;
            }
            else
            {
            }

            if (method.HasInterface())
            {
                methodNode.InterfaceType = new TypeInfo();
                methodNode.InterfaceType.AssemblyName    = method.InterfaceMethod.DeclaringType.Module.Assembly.Name.Name;
                methodNode.InterfaceType.AssemblyVersion = GetAssemblyVersion(method.InterfaceMethod);
                methodNode.InterfaceType.TypeName        = method.InterfaceMethod.DeclaringType.FullName;
            }

            if (method.HasAbstract())
            {
                methodNode.AbstractType = new TypeInfo();
                methodNode.AbstractType.AssemblyName    = method.AbstractMethod.DeclaringType.Module.Assembly.Name.Name;
                methodNode.AbstractType.AssemblyVersion = GetAssemblyVersion(method.AbstractMethod);
                methodNode.AbstractType.TypeName        = method.AbstractMethod.DeclaringType.FullName;
            }

            if (method.OverridesBaseClass())
            {
                methodNode.BaseClassType = new TypeInfo();
                methodNode.BaseClassType.AssemblyName    = method.VirtualMethod.DeclaringType.Module.Assembly.Name.Name;
                methodNode.BaseClassType.AssemblyVersion = GetAssemblyVersion(method.VirtualMethod);
                methodNode.BaseClassType.TypeName        = method.VirtualMethod.DeclaringType.FullName;
            }

            return(methodNode);
        }
Exemplo n.º 3
0
        private bool FindBaseClassMethod(MethodDefinition method, MethodObject methodNode)
        {
            // TODO currently only looks at direct base type
            if (ImplementationMethodsIndexedByTypeName.HasIndex(method.DeclaringType.BaseType.FullName))
            {
                var methodsOfBaseParent = ImplementationMethodsIndexedByTypeName.Get(method.DeclaringType.BaseType.FullName);
                var matchingMethod      = methodsOfBaseParent.FirstOrDefault(x => SignatureKeyService.GetMethodSignature(x).Equals(SignatureKeyService.GetMethodSignature(method)));
                if (matchingMethod != null)
                {
                    methodNode.VirtualMethod  = matchingMethod;
                    methodNode.ImplementsType = ImplementsType.Overrides;

                    return(true);
                }
            }

            return(false);
        }