private static bool TryGetCommonType( PrimitiveType primitiveType1, PrimitiveType primitiveType2, out EdmType commonType) { commonType = (EdmType)null; if (TypeSemantics.IsSubTypeOf(primitiveType1, primitiveType2)) { commonType = (EdmType)primitiveType2; return(true); } if (TypeSemantics.IsSubTypeOf(primitiveType2, primitiveType1)) { commonType = (EdmType)primitiveType1; return(true); } ReadOnlyCollection <PrimitiveType> commonSuperTypes = TypeSemantics.GetPrimitiveCommonSuperTypes(primitiveType1, primitiveType2); if (commonSuperTypes.Count <= 0) { return(false); } commonType = (EdmType)commonSuperTypes[0]; return(true); }
private static bool TryGetCommonPrimitiveType( TypeUsage type1, TypeUsage type2, out TypeUsage commonType) { commonType = (TypeUsage)null; if (TypeSemantics.IsPromotableTo(type1, type2)) { commonType = TypeSemantics.ForgetConstraints(type2); return(true); } if (TypeSemantics.IsPromotableTo(type2, type1)) { commonType = TypeSemantics.ForgetConstraints(type1); return(true); } ReadOnlyCollection <PrimitiveType> commonSuperTypes = TypeSemantics.GetPrimitiveCommonSuperTypes((PrimitiveType)type1.EdmType, (PrimitiveType)type2.EdmType); if (commonSuperTypes.Count == 0) { return(false); } commonType = TypeUsage.CreateDefaultTypeUsage((EdmType)commonSuperTypes[0]); return(null != commonType); }