Beispiel #1
0
        public static bool MethodMatch(MethodDefinition candidate, MethodDefinition method)
        {
            if (!candidate.IsVirtual)
            {
                return(false);
            }

            if (candidate.Name != method.Name)
            {
                return(false);
            }

            if (!Helpers.TypeMatch(candidate.ReturnType, method.ReturnType))
            {
                return(false);
            }

            if (candidate.Parameters.Count != method.Parameters.Count)
            {
                return(false);
            }

            for (int i = 0; i < candidate.Parameters.Count; i++)
            {
                if (!Helpers.TypeMatch(candidate.Parameters[i].ParameterType, method.Parameters[i].ParameterType))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        public static bool TypeMatch(GenericInstanceType a, GenericInstanceType b)
        {
            if (!Helpers.TypeMatch(a.ElementType, b.ElementType))
            {
                return(false);
            }

            if (a.GenericArguments.Count != b.GenericArguments.Count)
            {
                return(false);
            }

            if (a.GenericArguments.Count == 0)
            {
                return(true);
            }

            for (int i = 0; i < a.GenericArguments.Count; i++)
            {
                if (!Helpers.TypeMatch(a.GenericArguments[i], b.GenericArguments[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
        public static bool TypeMatch(IModifierType a, IModifierType b)
        {
            if (!Helpers.TypeMatch(a.ModifierType, b.ModifierType))
            {
                return(false);
            }

            return(Helpers.TypeMatch(a.ElementType, b.ElementType));
        }
Beispiel #4
0
        public static bool TypeMatch(TypeSpecification a, TypeSpecification b)
        {
            if (a is GenericInstanceType)
            {
                return(Helpers.TypeMatch((GenericInstanceType)a, (GenericInstanceType)b));
            }

            if (a is IModifierType)
            {
                return(Helpers.TypeMatch((IModifierType)a, (IModifierType)b));
            }

            return(Helpers.TypeMatch(a.ElementType, b.ElementType));
        }
Beispiel #5
0
        public static bool TypeMatch(TypeReference a, TypeReference b)
        {
            if (a is GenericParameter)
            {
                return(true);
            }

            if (a is TypeSpecification || b is TypeSpecification)
            {
                if (a.GetType() != b.GetType())
                {
                    return(false);
                }

                return(Helpers.TypeMatch((TypeSpecification)a, (TypeSpecification)b));
            }

            return(a.FullName == b.FullName);
        }