// <summary> // Get the "new" type corresponding to the input type. For structured types, // we return the flattened record type. // For collections of structured type, we return a new collection type of the corresponding flattened // type. // For enum types we return the underlying type of the enum type. // For strong spatial types we return the union type that includes the strong spatial type. // For everything else, we return the input type // </summary> // <param name="type"> the original type </param> // <returns> the new type (if any) </returns> private md.TypeUsage GetNewType(md.TypeUsage type) { if (TypeUtils.IsStructuredType(type)) { var typeInfo = GetTypeInfo(type); return(typeInfo.FlattenedTypeUsage); } md.TypeUsage elementType; if (TypeHelpers.TryGetCollectionElementType(type, out elementType)) { var newElementType = GetNewType(elementType); if (newElementType.EdmEquals(elementType)) { return(type); } else { return(TypeHelpers.CreateCollectionTypeUsage(newElementType)); } } if (TypeUtils.IsEnumerationType(type)) { return(TypeHelpers.CreateEnumUnderlyingTypeUsage(type)); } if (md.TypeSemantics.IsStrongSpatialType(type)) { return(TypeHelpers.CreateSpatialUnionTypeUsage(type)); } // simple scalar return(type); }
private TypeUsage GetNewType(TypeUsage type) { if (TypeUtils.IsStructuredType(type)) { return(this.GetTypeInfo(type).FlattenedTypeUsage); } TypeUsage elementType; if (TypeHelpers.TryGetCollectionElementType(type, out elementType)) { TypeUsage newType = this.GetNewType(elementType); if (newType.EdmEquals((MetadataItem)elementType)) { return(type); } return(TypeHelpers.CreateCollectionTypeUsage(newType)); } if (TypeUtils.IsEnumerationType(type)) { return(TypeHelpers.CreateEnumUnderlyingTypeUsage(type)); } if (TypeSemantics.IsStrongSpatialType(type)) { return(TypeHelpers.CreateSpatialUnionTypeUsage(type)); } return(type); }