Esempio n. 1
0
        public static bool TypeMatches(this TypeReference type, TypeReference matches)
        {
            if (type.GetNormalizedName() != matches.GetNormalizedName())
                return false;

            if (type.IsGenericParameter != type.IsGenericParameter)
                return false;

            if (type.IsGenericParameter)
                return true;

            if (type.Resolve().GenericParameters.Count != matches.Resolve().GenericParameters.Count)
                return false;

            if (type.IsGenericInstance && matches.IsGenericInstance)
            {
                var genArgs1 = ((GenericInstanceType)type).GenericArguments;
                var genArgs2 = ((GenericInstanceType)matches).GenericArguments;
                for (int i = 0; i < genArgs1.Count; i++)
                {
                    if (!genArgs1[i].TypeMatches(genArgs2[i]))
                        return false;
                }
            }

            return true;
        }