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
Implement asynchronous support in RawValueWriter #2121
Conversation
2fb561b
to
7f9fbd0
Compare
string valueAsString; | ||
if (value is ODataEnumValue enumValue) | ||
{ | ||
return this.textWriter.WriteAsync(enumValue.Value); | ||
} | ||
else if (value is Geometry || value is Geography) | ||
{ | ||
return TaskUtils.GetTaskForSynchronousOperation( | ||
() => PrimitiveConverter.Instance.WriteJsonLight(value, jsonWriter)); | ||
} | ||
else if (ODataRawValueUtils.TryConvertPrimitiveToString(value, out valueAsString)) | ||
{ | ||
return this.textWriter.WriteAsync(valueAsString); | ||
} | ||
else | ||
{ | ||
// Value is neither enum nor primitive | ||
return TaskUtils.GetFaultedTask( | ||
new ODataException(Strings.ODataUtils_CannotConvertValueToRawString(value.GetType().FullName))); | ||
} |
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.
string valueAsString; | |
if (value is ODataEnumValue enumValue) | |
{ | |
return this.textWriter.WriteAsync(enumValue.Value); | |
} | |
else if (value is Geometry || value is Geography) | |
{ | |
return TaskUtils.GetTaskForSynchronousOperation( | |
() => PrimitiveConverter.Instance.WriteJsonLight(value, jsonWriter)); | |
} | |
else if (ODataRawValueUtils.TryConvertPrimitiveToString(value, out valueAsString)) | |
{ | |
return this.textWriter.WriteAsync(valueAsString); | |
} | |
else | |
{ | |
// Value is neither enum nor primitive | |
return TaskUtils.GetFaultedTask( | |
new ODataException(Strings.ODataUtils_CannotConvertValueToRawString(value.GetType().FullName))); | |
} | |
if (value is ODataEnumValue enumValue) | |
{ | |
return this.textWriter.WriteAsync(enumValue.Value); | |
} | |
if (value is Geometry || value is Geography) | |
{ | |
return TaskUtils.GetTaskForSynchronousOperation( | |
() => PrimitiveConverter.Instance.WriteJsonLight(value, jsonWriter)); | |
} | |
if (ODataRawValueUtils.TryConvertPrimitiveToString(value, out var valueAsString)) | |
{ | |
return this.textWriter.WriteAsync(valueAsString); | |
} | |
// Value is neither enum nor primitive | |
return TaskUtils.GetFaultedTask( | |
new ODataException(Strings.ODataUtils_CannotConvertValueToRawString(value.GetType().FullName))); |
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.
LGTM
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.
Should this class also implement IAsyncDisposable
?
Not necessary. this.textWriter.Dispose();
this.textWriter = null; In this case |
7f9fbd0
to
e7d1458
Compare
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
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.
lgtm
Issues
This pull request is in partial fulfilment of issue #2019.
Description
Implement asynchronous support in
RawValueWriter
.Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.