/// <summary> /// Prepare the type name for writing. /// 1) If it is primitive type, remove the Edm. prefix. /// 2) If it is a non-primitive type or 4.0, prefix with #. /// </summary> /// <param name="typeName">The type name to write</param> /// <param name="version">OData Version of payload being written</param> /// <returns>The type name for writing</returns> internal static string PrefixTypeNameForWriting(string typeName, ODataVersion version) { if (!string.IsNullOrEmpty(typeName)) { string itemTypeName = EdmLibraryExtensions.GetCollectionItemTypeName(typeName); if (itemTypeName == null) { IEdmSchemaType primitiveType = EdmLibraryExtensions.ResolvePrimitiveTypeName(typeName); if (primitiveType != null) { typeName = primitiveType.ShortQualifiedName(); return(version < ODataVersion.V401 ? PrefixTypeName(typeName) : typeName); } } else { IEdmSchemaType primitiveType = EdmLibraryExtensions.ResolvePrimitiveTypeName(itemTypeName); if (primitiveType != null) { typeName = EdmLibraryExtensions.GetCollectionTypeName(primitiveType.ShortQualifiedName()); return(version < ODataVersion.V401 ? PrefixTypeName(typeName) : typeName); } } } return(PrefixTypeName(typeName)); }
/// <summary> /// Remove the Edm. prefix from the type name if it is primitive type. /// </summary> /// <param name="typeName">The type name to remove the Edm. prefix</param> /// <returns>The type name without the Edm. Prefix</returns> internal static string RemoveEdmPrefixFromTypeName(string typeName) { if (!string.IsNullOrEmpty(typeName)) { string itemTypeName = EdmLibraryExtensions.GetCollectionItemTypeName(typeName); if (itemTypeName == null) { IEdmSchemaType primitiveType = EdmLibraryExtensions.ResolvePrimitiveTypeName(typeName); if (primitiveType != null) { return(primitiveType.ShortQualifiedName()); } } else { IEdmSchemaType primitiveType = EdmLibraryExtensions.ResolvePrimitiveTypeName(itemTypeName); if (primitiveType != null) { return(EdmLibraryExtensions.GetCollectionTypeName(primitiveType.ShortQualifiedName())); } } } return(typeName); }
protected string RemoveEdmPrefixFromTypeName(string typeName) { string itemTypeName = GetCollectionItemTypeName(typeName); if (itemTypeName == null) { // This is not a collection type IEdmSchemaType edmType = EdmCoreModel.Instance.FindDeclaredType(typeName); if (edmType != null) { return(edmType.ShortQualifiedName()); } } else { // This is a collection type IEdmSchemaType edmType = EdmCoreModel.Instance.FindDeclaredType(itemTypeName); if (edmType != null) { return(CollectionTypeQualifier + String.Format("({0})", edmType.ShortQualifiedName())); } } return(typeName); }