-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adds more write overloads to Utf8Json #4209
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
Changes from 2 commits
de62914
fc289b1
ffc4e46
f365b30
b07e0a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ internal class BulkRequestFormatter : IJsonFormatter<IBulkRequest> | |
{ | ||
private const byte Newline = (byte)'\n'; | ||
|
||
private static SourceWriteFormatter<object> SourceWriter { get; } = new SourceWriteFormatter<object>(); | ||
|
||
public IBulkRequest Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) => | ||
throw new NotSupportedException(); | ||
|
||
|
@@ -17,16 +19,13 @@ public void Serialize(ref JsonWriter writer, IBulkRequest value, IJsonFormatterR | |
return; | ||
|
||
var settings = formatterResolver.GetConnectionSettings(); | ||
var memoryStreamFactory = settings.MemoryStreamFactory; | ||
var requestResponseSerializer = settings.RequestResponseSerializer; | ||
var sourceSerializer = settings.SourceSerializer; | ||
var inferrer = settings.Inferrer; | ||
var formatter = formatterResolver.GetFormatter<object>(); | ||
|
||
for (var index = 0; index < value.Operations.Count; index++) | ||
{ | ||
var op = value.Operations[index]; | ||
op.Index = op.Index ?? value.Index ?? op.ClrType; | ||
op.Index ??= value.Index ?? op.ClrType; | ||
if (op.Index.Equals(value.Index)) op.Index = null; | ||
op.Id = op.GetIdForOperation(inferrer); | ||
op.Routing = op.GetRoutingForOperation(inferrer); | ||
|
@@ -42,12 +41,7 @@ public void Serialize(ref JsonWriter writer, IBulkRequest value, IJsonFormatterR | |
if (body == null) | ||
continue; | ||
|
||
var bodySerializer = op.Operation == "update" || body is ILazyDocument | ||
? requestResponseSerializer | ||
: sourceSerializer; | ||
|
||
var bodyBytes = bodySerializer.SerializeToBytes(body, memoryStreamFactory, SerializationFormatting.None); | ||
writer.WriteRaw(bodyBytes); | ||
SourceWriter.Serialize(ref writer, body, formatterResolver); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a behavioural change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavioural change looks like the Before, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh you are right, will address! |
||
writer.WriteRaw(Newline); | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.