Example #1
0
        internal static bool TryGetCommonType(
            TypeUsage type1,
            TypeUsage type2,
            out TypeUsage commonType)
        {
            commonType = (TypeUsage)null;
            if (type1.EdmEquals((MetadataItem)type2))
            {
                commonType = TypeSemantics.ForgetConstraints(type2);
                return(true);
            }
            if (Helper.IsPrimitiveType(type1.EdmType) && Helper.IsPrimitiveType(type2.EdmType))
            {
                return(TypeSemantics.TryGetCommonPrimitiveType(type1, type2, out commonType));
            }
            EdmType commonEdmType;

            if (TypeSemantics.TryGetCommonType(type1.EdmType, type2.EdmType, out commonEdmType))
            {
                commonType = TypeSemantics.ForgetConstraints(TypeUsage.Create(commonEdmType));
                return(true);
            }
            commonType = (TypeUsage)null;
            return(false);
        }