-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to override Primitive Serialization and deserialization of Payload. #108 #139
Conversation
…load. OData#108 Added a serializer/deserializer extensibility point, to convert Json Payload value to Primitive type. And allowed skipping the validation.
1-Passes values as Binary, and expect the standard Base64 string, 2-Passes values as string, and expect pass through,
Hi @shahzorkhan123, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
/// <summary> | ||
/// Provides the default of primitive payload value converter | ||
/// </summary> | ||
public static class PrimitivePayloadValueConverterProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you're using global static variable to store the converter here, all models would shall the same value converter. This would breaks when a service wants to deal with 2+ models with different configurations at the same time.
We can consider leverage model.SetAnnotationValue & model.GetAnnotationValue to make it a per model settings. Please refer to src\Microsoft.OData.Edm\ExtensionMethods::SetPrimitiveValueConverter for more information.
Also the tests run in PrimitiveValuesRoundtripJsonLightTests class would randomly fails as one case would call global SetPrimitivePayloadValueConverter which changes global serialization/deserialization behaviour.
@karataliu: I didn't added it there, because this is very limited to Payload serialization/deserialization, and shouldn't be added Edm Lib. I can however expose the an API to Please suggest. |
Yes, I didn't mean you should put those inside EdmLib. But just to show that this is a way to make some object bound to certain model. My point is the custom payload value converter should not be a global static configuration, but a model specific one. I'd suggest APIs to be something like the following in ExtensionMethods.cs of ODataLib:
You might maintain a static global dictionary to map the model with certain converter, but the dictionary size would keep growing if you're to continue adding new models to it, as some service may use dynamic models. But if using model.SetAnnotationValue that won't be an issue. |
And fixed the testcases
Updated as per discussion. |
We're reviewing the code. Thanks. |
Merged in commit 11c4467 |
Shahzor Khan @ 30-Mar-15 5:38:46 PM
No way to override Primitive Serialization and deserialization of Payload. #108