Example #1
0
        public static bool ExtendsClass(ITypeDefinition derivedCl, ITypeDefinition baseCl)
        {
            if (derivedCl == null || baseCl == null)
            {
                return(false);
            }
            ITypeDefinition analBaseCl = Stubber.GetTypeToAnalyze(baseCl);

            if (analBaseCl != null && tdc.Equals(derivedCl, analBaseCl))
            {
                return(true);
            }

            foreach (ITypeReference bcl in derivedCl.BaseClasses)
            {
                ITypeDefinition analBcl = Stubber.GetTypeToAnalyze(bcl.ResolvedType);
                if (analBcl != null && tdc.Equals(baseCl, analBcl))
                {
                    return(true);
                }
            }
            foreach (ITypeReference bcl in derivedCl.BaseClasses)
            {
                ITypeDefinition analBcl = Stubber.GetTypeToAnalyze(bcl.ResolvedType);
                if (ExtendsClass(analBcl, baseCl))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public static bool ImplementsInterface(ITypeDefinition tgt, ITypeDefinition queryItf)
        {
            if (queryItf == null || tgt == null)
            {
                return(false);
            }

            foreach (ITypeReference itf in tgt.Interfaces)
            {
                ITypeDefinition analItf = Stubber.GetTypeToAnalyze(itf.ResolvedType);
                if (analItf != null && tdc.Equals(queryItf, analItf.ResolvedType))
                {
                    return(true);
                }
            }
            foreach (ITypeReference itf in tgt.Interfaces)
            {
                ITypeReference analItf = Stubber.GetTypeToAnalyze(itf.ResolvedType);
                if (analItf != null && ImplementsInterface(analItf.ResolvedType, queryItf))
                {
                    return(true);
                }
            }
            foreach (ITypeReference bcl in tgt.BaseClasses)
            {
                ITypeReference analBcl = Stubber.GetTypeToAnalyze(bcl.ResolvedType);
                if (analBcl != null && ImplementsInterface(analBcl.ResolvedType, queryItf))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        public static IMethodDefinition GetMethodSignMatchRecursive(ITypeDefinition ty, IMethodDefinition meth)
        {
            IMethodDefinition signMatchMeth = GetMethodSignMatch(ty, meth);

            if (signMatchMeth != null)
            {
                return(signMatchMeth);
            }

            foreach (ITypeReference bty in ty.BaseClasses)
            {
                ITypeDefinition analBty = Stubber.GetTypeToAnalyze(bty.ResolvedType);
                if (analBty != null && !Stubber.SuppressF(analBty))
                {
                    return(GetMethodSignMatchRecursive(analBty, meth));
                }
            }
            return(null);
        }