/// <summary> /// Writes the odata.type instance annotation with the specified type name. /// </summary> /// <param name="typeName">The type name to write.</param> public void WriteODataTypeInstanceAnnotation(string typeName) { Debug.Assert(typeName != null, "typeName != null"); // "@odata.type": #"typename" WriteInstanceAnnotationName(ODataAnnotationNames.ODataType); jsonWriter.WriteValue(PrefixTypeName(WriterUtils.RemoveEdmPrefixFromTypeName(typeName))); }
/// <summary> /// Writes the m:type attribute for a property given the name of the type. /// </summary> /// <param name="typeName">The type name to write.</param> private void WritePropertyTypeAttribute(string typeName) { // m:type attribute this.XmlWriter.WriteAttributeString( AtomConstants.ODataMetadataNamespacePrefix, AtomConstants.AtomTypeAttributeName, AtomConstants.ODataMetadataNamespace, ODataAtomWriterUtils.PrefixTypeName(WriterUtils.RemoveEdmPrefixFromTypeName(typeName))); }
/// <summary> /// Writes the odata.type propert annotation for the specified property with the specified type name. /// </summary> /// <param name="propertyName">The name of the property for which to write the odata.type annotation.</param> /// <param name="typeName">The type name to write.</param> public void WriteODataTypePropertyAnnotation(string propertyName, string typeName) { Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)"); Debug.Assert(typeName != null, "typeName != null"); // "<propertyName>@odata.type": #"typename" WritePropertyAnnotationName(propertyName, ODataAnnotationNames.ODataType); jsonWriter.WriteValue(PrefixTypeName(WriterUtils.RemoveEdmPrefixFromTypeName(typeName))); }
public void TypeNameShouldBeWrittenIfSpatialValueIsMoreDerivedThanMetadataType() { var typeFromMetadata = EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.Geography, true); var typeFromValue = EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, false); var result = this.typeNameOracle.GetValueTypeNameForWriting(new ODataPrimitiveValue(Microsoft.Spatial.GeographyPoint.Create(42, 42)), typeFromMetadata, typeFromValue, /* isOpenProperty*/ false); result.Should().Be("Edm.GeographyPoint"); WriterUtils.RemoveEdmPrefixFromTypeName(result).Should().Be("GeographyPoint"); }
public void TypeNameShouldBeWrittenForUndeclaredCollectionProperty() { var typeFromValue = EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false)); var result = this.typeNameOracle.GetValueTypeNameForWriting(new ODataCollectionValue() { TypeName = "Collection(String)" }, null, typeFromValue, /* isOpenProperty*/ true); result.Should().Be("Collection(Edm.String)"); WriterUtils.RemoveEdmPrefixFromTypeName(result).Should().Be("Collection(String)"); }