// <summary> // Determines if a common super type (LUB) exists between type1 and type2. // </summary> // <returns> true if a common super type between type1 and type2 exists and out commonType represents the common super type. false otherwise along with commonType as null </returns> internal static bool TryGetCommonType(TypeUsage type1, TypeUsage type2, out TypeUsage commonType) { DebugCheck.NotNull(type1); DebugCheck.NotNull(type2); commonType = null; if (type1.EdmEquals(type2)) { commonType = ForgetConstraints(type2); return(true); } if (Helper.IsPrimitiveType(type1.EdmType) && Helper.IsPrimitiveType(type2.EdmType)) { return(TryGetCommonPrimitiveType(type1, type2, out commonType)); } EdmType commonEdmType; if (TryGetCommonType(type1.EdmType, type2.EdmType, out commonEdmType)) { commonType = ForgetConstraints(TypeUsage.Create(commonEdmType)); return(true); } commonType = null; return(false); }
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); }
internal static bool IsSubTypeOf(TypeUsage subType, TypeUsage superType) { if (subType.EdmEquals((MetadataItem)superType)) { return(true); } if (Helper.IsPrimitiveType(subType.EdmType) && Helper.IsPrimitiveType(superType.EdmType)) { return(TypeSemantics.IsPrimitiveTypeSubTypeOf(subType, superType)); } return(subType.IsSubtypeOf(superType)); }
// <summary> // determines if subType is equal to or a sub-type of superType. // </summary> // <returns> true if subType is equal to or a sub-type of superType, false otherwise </returns> internal static bool IsSubTypeOf(TypeUsage subType, TypeUsage superType) { DebugCheck.NotNull(subType); DebugCheck.NotNull(superType); if (subType.EdmEquals(superType)) { return(true); } if (Helper.IsPrimitiveType(subType.EdmType) && Helper.IsPrimitiveType(superType.EdmType)) { return(IsPrimitiveTypeSubTypeOf(subType, superType)); } return(subType.IsSubtypeOf(superType)); }