internal static IEdmType ResolveTypeName( IEdmModel model, IEdmType expectedType, string typeName, Func <IEdmType, string, IEdmType> customTypeResolver, ODataVersion version, out EdmTypeKind typeKind) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(model != null, "model != null"); Debug.Assert(typeName != null, "typeName != null"); IEdmType resolvedType = null; // Collection types should only be recognized in V3 and higher. string itemTypeName = version >= ODataVersion.V3 ? EdmLibraryExtensions.GetCollectionItemTypeName(typeName) : null; if (itemTypeName == null) { // Note: we require the type resolver or the model to also resolve // primitive types. if (customTypeResolver != null && model.IsUserModel()) { resolvedType = customTypeResolver(expectedType, typeName); if (resolvedType == null) { // If a type resolver is specified it must never return null. throw new ODataException(Strings.MetadataUtils_ResolveTypeName(typeName)); } } else { resolvedType = model.FindType(typeName); } // Spatial types are only recognized in V3 and higher. if (version < ODataVersion.V3 && resolvedType != null && resolvedType.IsSpatial()) { resolvedType = null; } typeKind = resolvedType == null ? EdmTypeKind.None : resolvedType.TypeKind; } else { // Collection typeKind = EdmTypeKind.Collection; EdmTypeKind itemTypeKind; IEdmType expectedItemType = null; if (customTypeResolver != null && expectedType != null && expectedType.TypeKind == EdmTypeKind.Collection) { expectedItemType = ((IEdmCollectionType)expectedType).ElementType.Definition; } IEdmType itemType = ResolveTypeName(model, expectedItemType, itemTypeName, customTypeResolver, version, out itemTypeKind); if (itemType != null) { resolvedType = EdmLibraryExtensions.GetCollectionType(itemType); } } return(resolvedType); }