/// <summary> /// Initializes a new instance of the <see cref="ODataJsonLightValueSerializer"/> class. /// </summary> /// <param name="propertySerializer">The property serializer to use when writing complex values.</param> /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param> internal ODataJsonLightValueSerializer(ODataJsonLightPropertySerializer propertySerializer, bool initContextUriBuilder = false) : base(propertySerializer.JsonLightOutputContext, initContextUriBuilder) { this.propertySerializer = propertySerializer; }
private string SerializeProperty(ODataProperty odataProperty) { MemoryStream outputStream = new MemoryStream(); ODataJsonLightOutputContext jsonLightOutputContext = this.CreateJsonLightOutputContext(outputStream); var serializer = new ODataJsonLightPropertySerializer(jsonLightOutputContext); jsonLightOutputContext.JsonWriter.StartObjectScope(); serializer.WriteProperties( this.entityType, new[] { odataProperty }, /*isComplexValue*/ false, new DuplicatePropertyNamesChecker(allowDuplicateProperties: true, isResponse: true), ProjectedPropertiesAnnotation.AllProjectedPropertiesInstance); jsonLightOutputContext.JsonWriter.EndObjectScope(); jsonLightOutputContext.Flush(); outputStream.Position = 0; string result = new StreamReader(outputStream).ReadToEnd(); return result; }
/// <summary> /// Writes an <see cref="ODataProperty"/> as message payload. /// </summary> /// <param name="property">The property to write.</param> private void WritePropertyImplementation(ODataProperty property) { ODataJsonLightPropertySerializer jsonLightPropertySerializer = new ODataJsonLightPropertySerializer(this, /*initContextUriBuilder*/ true); jsonLightPropertySerializer.WriteTopLevelProperty(property); }
/// <summary> /// Writes an <see cref="ODataProperty"/> as message payload. /// </summary> /// <param name="property">The property to write.</param> private void WritePropertyImplementation(ODataProperty property) { ODataJsonLightPropertySerializer jsonLightPropertySerializer = new ODataJsonLightPropertySerializer(this, /*initContextUriBuilder*/ true); jsonLightPropertySerializer.WriteTopLevelProperty(property); }
/// <summary> /// Initializes a new instance of the <see cref="ODataJsonLightValueSerializer"/> class. /// </summary> /// <param name="propertySerializer">The property serializer to use when writing complex values.</param> /// <param name="initContextUriBuilder">Whether contextUriBuilder should be initialized.</param> internal ODataJsonLightValueSerializer(ODataJsonLightPropertySerializer propertySerializer, bool initContextUriBuilder = false) : base(propertySerializer.JsonLightOutputContext, initContextUriBuilder) { this.propertySerializer = propertySerializer; }