Mosa.Compiler.Framework.MosaTypeLayout.FindInterfaceMethod C# (CSharp) Method

FindInterfaceMethod() private method

private FindInterfaceMethod ( MosaType type, MosaMethod interfaceMethod ) : MosaMethod
type MosaType
interfaceMethod MosaMethod
return MosaMethod
        private MosaMethod FindInterfaceMethod(MosaType type, MosaMethod interfaceMethod)
        {
            MosaMethod methodFound = null;

            if (type.BaseType != null)
            {
                methodFound = FindImplicitInterfaceMethod(type.BaseType, interfaceMethod);
            }

            var cleanInterfaceMethodName = GetCleanMethodName(interfaceMethod.Name);

            foreach (var method in type.Methods)
            {
                if (IsExplicitInterfaceMethod(method.FullName) && methodFound != null)
                    continue;

                string cleanMethodName = GetCleanMethodName(method.Name);

                if (cleanInterfaceMethodName.Equals(cleanMethodName))
                {
                    if (interfaceMethod.Equals(method))
                    {
                        return method;
                    }
                }
            }

            if (type.BaseType != null)
            {
                methodFound = FindInterfaceMethod(type.BaseType, interfaceMethod);
            }

            if (methodFound != null)
                return methodFound;

            throw new InvalidOperationException(@"Failed to find implicit interface implementation for type " + type + " and interface method " + interfaceMethod);
        }