Skip to content

Commit

Permalink
Store payloadvalueconverter to ODataOutputContext for performance ODa…
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe-ms committed Feb 1, 2016
1 parent e1f4ff0 commit f2c7cd9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ sln/packages/

# Test artifacts
test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl1.csdl
test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl2.csdl
test/FunctionalTests/Tests/Data/Northwind/Northwind.csdl2.csdl

# Symbol
*.pdb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
15 changes: 15 additions & 0 deletions src/Microsoft.OData.Core/ODataOutputContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public abstract class ODataOutputContext : IDisposable
/// <summary>The type resolver to use.</summary>
private readonly EdmTypeResolver edmTypeResolver;

/// <summary>The payload value converter to use.</summary>
private readonly ODataPayloadValueConverter payloadValueConverter;

/// <summary>
/// Constructor.
/// </summary>
Expand Down Expand Up @@ -72,6 +75,7 @@ protected ODataOutputContext(
this.model = model ?? EdmCoreModel.Instance;
this.urlResolver = urlResolver;
this.edmTypeResolver = EdmTypeWriterResolver.Instance;
this.payloadValueConverter = this.model.GetPayloadValueConverter();
}

/// <summary>
Expand Down Expand Up @@ -141,6 +145,17 @@ internal EdmTypeResolver EdmTypeResolver
}
}

/// <summary>
/// The payload value converter to use
/// </summary>
internal ODataPayloadValueConverter PayloadValueConverter
{
get
{
return this.payloadValueConverter;
}
}

/// <summary>
/// The Context Url level used when writing.
/// </summary>
Expand Down

0 comments on commit f2c7cd9

Please sign in to comment.