private static bool CompareTypes(TypeUsage fromType, TypeUsage toType, bool equivalenceOnly) { if (object.ReferenceEquals((object)fromType, (object)toType)) { return(true); } if (fromType.EdmType.BuiltInTypeKind != toType.EdmType.BuiltInTypeKind) { return(false); } if (fromType.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType) { return(TypeSemantics.CompareTypes(((CollectionType)fromType.EdmType).TypeUsage, ((CollectionType)toType.EdmType).TypeUsage, equivalenceOnly)); } if (fromType.EdmType.BuiltInTypeKind == BuiltInTypeKind.RefType) { return(((RefType)fromType.EdmType).ElementType.EdmEquals((MetadataItem)((RefType)toType.EdmType).ElementType)); } if (fromType.EdmType.BuiltInTypeKind != BuiltInTypeKind.RowType) { return(fromType.EdmType.EdmEquals((MetadataItem)toType.EdmType)); } RowType edmType1 = (RowType)fromType.EdmType; RowType edmType2 = (RowType)toType.EdmType; if (edmType1.Properties.Count != edmType2.Properties.Count) { return(false); } for (int index = 0; index < edmType1.Properties.Count; ++index) { EdmProperty property1 = edmType1.Properties[index]; EdmProperty property2 = edmType2.Properties[index]; if (!equivalenceOnly && property1.Name != property2.Name || !TypeSemantics.CompareTypes(property1.TypeUsage, property2.TypeUsage, equivalenceOnly)) { return(false); } } return(true); }
internal static bool IsStructurallyEqual(TypeUsage fromType, TypeUsage toType) { return(TypeSemantics.CompareTypes(fromType, toType, true)); }
internal static bool IsEqual(TypeUsage type1, TypeUsage type2) { return(TypeSemantics.CompareTypes(type1, type2, false)); }