You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/client-concepts/high-level/inference/field-inference.asciidoc
-4Lines changed: 0 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -500,13 +500,9 @@ class Precedence
500
500
}
501
501
----
502
502
<1> Even though this property has a NEST property mapping _and_ a `JsonProperty` attribute, We are going to provide a hard rename for it on ConnectionSettings later that should win.
503
-
504
503
<2> This property has both a NEST attribute and a `JsonProperty`, NEST should win.
505
-
506
504
<3> We should take the json property into account by itself
507
-
508
505
<4> This property we are going to special case in our custom serializer to resolve to ask
509
-
510
506
<5> We are going to register a DefaultFieldNameInferrer on ConnectionSettings that will uppercase all properties.
511
507
512
508
Here we create a custom serializer that renames any property named `AskSerializer` to `ask`
<3> The index names here come from the Connection Settings passed to `TestClient`. See the documentation on <<index-name-inference, Index Name Inference>> for more details.
public int CallToContractConverter { get; set; } = 0;
333
356
334
-
protected override IList<Func<Type, JsonConverter>> ContractConverters => new List<Func<Type, JsonConverter>> <2>
357
+
protected override IList<Func<Type, JsonConverter>> ContractConverters => new List<Func<Type, JsonConverter>> <3>
335
358
{
336
359
t => {
337
360
CallToContractConverter++;
@@ -341,9 +364,11 @@ public class MyJsonNetSerializer : JsonNetSerializer
341
364
342
365
}
343
366
----
344
-
<1> Override ModifyJsonSerializerSettings if you need access to `JsonSerializerSettings`
367
+
<1> Call this constructor if you only need access to `JsonSerializerSettings` without local state
368
+
369
+
<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with local state
345
370
346
-
<2> You can inject contract resolved converters by implementing the ContractConverters property. This can be much faster then registering them on `JsonSerializerSettings.Converters`
371
+
<3> You can inject contract resolved converters by implementing the ContractConverters property. This can be much faster then registering them on `JsonSerializerSettings.Converters`
347
372
348
373
You can then register a factory on `ConnectionSettings` to create an instance of your subclass instead.
349
374
This is **_called once per instance_** of ConnectionSettings.
:base(settings,(s,csv)=>s.PreserveReferencesHandling=PreserveReferencesHandling.All)//<1> Call this constructor if you only need access to `JsonSerializerSettings` without state
324
+
:base(settings,(s,csv)=>s.PreserveReferencesHandling=PreserveReferencesHandling.All)//<1> Call this constructor if you only need access to `JsonSerializerSettings` without local state
323
325
{
324
-
OverwriteDefaultSerializers((s,cvs)=>ModifySerializerSettings(s));//<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with state
326
+
OverwriteDefaultSerializers((s,cvs)=>ModifySerializerSettings(s));//<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with local state
0 commit comments