diff --git a/.gitignore b/.gitignore index e8cfd94671..486426e968 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,7 @@ sln/packages/ # Test artifacts test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl1.csdl -test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl2.csdl \ No newline at end of file +test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl2.csdl + +# Symbol +*.pdb \ No newline at end of file diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs index e9a906e260..8e51a59935 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightValueSerializer.cs @@ -350,7 +350,7 @@ public void WritePrimitiveValue( value = this.Model.ConvertToUnderlyingTypeIfUIntValue(value, expectedTypeReference); IEdmPrimitiveTypeReference actualTypeReference = EdmLibraryExtensions.GetPrimitiveTypeReference(value.GetType()); - ODataPayloadValueConverter converter = this.Model.GetPayloadValueConverter(); + ODataPayloadValueConverter converter = this.JsonLightOutputContext.PayloadValueConverter; // Skip validation if user has set custom PayloadValueConverter if (expectedTypeReference != null && converter.GetType() == typeof(ODataPayloadValueConverter)) diff --git a/src/Microsoft.OData.Core/ODataOutputContext.cs b/src/Microsoft.OData.Core/ODataOutputContext.cs index 4c3deabf28..414de75b96 100644 --- a/src/Microsoft.OData.Core/ODataOutputContext.cs +++ b/src/Microsoft.OData.Core/ODataOutputContext.cs @@ -45,6 +45,9 @@ public abstract class ODataOutputContext : IDisposable /// The type resolver to use. private readonly EdmTypeResolver edmTypeResolver; + /// The payload value converter to use. + private readonly ODataPayloadValueConverter payloadValueConverter; + /// /// Constructor. /// @@ -72,6 +75,7 @@ protected ODataOutputContext( this.model = model ?? EdmCoreModel.Instance; this.urlResolver = urlResolver; this.edmTypeResolver = EdmTypeWriterResolver.Instance; + this.payloadValueConverter = this.model.GetPayloadValueConverter(); } /// @@ -141,6 +145,17 @@ internal EdmTypeResolver EdmTypeResolver } } + /// + /// The payload value converter to use + /// + internal ODataPayloadValueConverter PayloadValueConverter + { + get + { + return this.payloadValueConverter; + } + } + /// /// The Context Url level used when writing. ///