Пример #1
0
        static bool AreEqual(GenericParameter a, GenericParameter b)
        {
            if (ReferenceEquals(a, b))
            {
                return(true);
            }

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

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

            var aOwnerType = a.Owner as TypeReference;

            if (aOwnerType != null && AreEqual(aOwnerType, b.Owner as TypeReference))
            {
                return(true);
            }

            var aOwnerMethod = a.Owner as MethodReference;

            if (aOwnerMethod != null && MethodReferenceComparer.AreEqual(aOwnerMethod, b.Owner as MethodReference))
            {
                return(true);
            }

            return(false);
        }
        static bool AreEqual(GenericParameter a, GenericParameter b, TypeComparisonMode comparisonMode = TypeComparisonMode.Exact)
        {
            if (ReferenceEquals(a, b))
            {
                return(true);
            }

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

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

            var aOwnerType = a.Owner as TypeReference;

            if (aOwnerType != null && AreEqual(aOwnerType, b.Owner as TypeReference, comparisonMode))
            {
                return(true);
            }

            var aOwnerMethod = a.Owner as MethodReference;

            if (aOwnerMethod != null && comparisonMode != TypeComparisonMode.SignatureOnlyLoose && MethodReferenceComparer.AreEqual(aOwnerMethod, b.Owner as MethodReference))
            {
                return(true);
            }

            return(comparisonMode == TypeComparisonMode.SignatureOnly || comparisonMode == TypeComparisonMode.SignatureOnlyLoose);
        }