Ejemplo n.º 1
0
        public bool AreSame(RuntimicSystemModel model, Collection <ParameterDefinition> a, Collection <ParameterDefinition> b, MethodReference bMethod)
        {
            var count = a.Count;

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

            if (count == 0)
            {
                return(true);
            }

            for (int i = 0; i < count; i++)
            {
                var aType = a[i].ParameterType;

                var bType = b[i].ParameterType;

                if (bMethod != null)
                {
                    bType = ResolveTypeParameterIfPresent(model, bMethod, bType);
                }

                if (!Types.AreSame(aType, bType))
                {
                    return(false);
                }
            }


            return(true);
        }
Ejemplo n.º 2
0
        public bool AreSame(RuntimicSystemModel model, MethodReference methodDefinition, MethodReference methodReference, bool resolveTypeParametersIfPresentInMethodB)
        {
            if (methodDefinition.Name != methodReference.Name)
            {
                return(false);
            }

            if (methodDefinition.HasGenericParameters != methodReference.HasGenericParameters)
            {
                return(false);
            }

            if (methodDefinition.HasGenericParameters && methodDefinition.GenericParameters.Count != methodReference.GenericParameters.Count)
            {
                return(false);
            }

            if (!Types.AreSame(methodDefinition.ReturnType, methodReference.ReturnType))
            {
                return(false);
            }

            if (IsVarArg(methodDefinition) != IsVarArg(methodReference))
            {
                return(false);
            }

            if (IsVarArg(methodDefinition) && IsVarArgCallTo(methodDefinition, methodReference))
            {
                return(true);
            }

            if (methodDefinition.HasParameters != methodReference.HasParameters)
            {
                return(false);
            }

            if (!methodDefinition.HasParameters && !methodReference.HasParameters)
            {
                return(true);
            }

            MethodReference methodReferenceToResolve = resolveTypeParametersIfPresentInMethodB ? methodReference : null;

            if (!AreSame(model, methodDefinition.Parameters, methodReference.Parameters, methodReferenceToResolve))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public bool IsVarArgCallTo(MethodReference method, MethodReference reference)
        {
            if (method.Parameters.Count >= reference.Parameters.Count)
            {
                return(false);
            }

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

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

            return(true);
        }