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: sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,8 @@ The samples project demonstrates the following:
22
22
23
23
## Creating the digital twins client
24
24
25
+
### Simple creation
26
+
25
27
To create a new digital twins client, you need the endpoint to an Azure Digital Twin instance and credentials.
26
28
In the sample below, you can set `AdtEndpoint`, `TenantId`, `ClientId`, and `ClientSecret` as command-line arguments.
27
29
The client requires an instance of [TokenCredential](https://docs.microsoft.com/dotnet/api/azure.core.tokencredential?view=azure-dotnet).
@@ -40,13 +42,31 @@ var client = new DigitalTwinsClient(
40
42
tokenCredential);
41
43
```
42
44
43
-
Also, if you need to override pipeline behavior, such as provide your own HttpClient instance, you can do that via the other constructor that takes a client options.
45
+
### Override options
46
+
47
+
If you need to override pipeline behavior, such as provide your own HttpClient instance, you can do that via the other constructor that takes a
The digital twins client has methods that will serialize your custom digital twins and relationship types for transport, and deserialize the response back to a type specified by you.
60
+
The default object serializer, [JsonObjectSerializer](https://docs.microsoft.com/dotnet/api/azure.core.serialization.jsonobjectserializer?view=azure-dotnet),
61
+
works using the `System.Text.Json` library.
62
+
It uses a default [JsonSerializerOptions](https://docs.microsoft.com/dotnet/api/system.text.json.jsonserializeroptions?view=net-5.0) instance.
63
+
64
+
Set the `Serializer` property to a custom instance of `JsonObjectSerializer` or your own implementation that inherits from
One reason for customizing would be to provide custom de/serialization settings, for example setting the `IgnoreNullValues` property to `true`.
68
+
See more examples and options of working with `JsonSerializerOptions`[here](https://docs.microsoft.com/dotnet/standard/serialization/system-text-json-how-to?pivots=dotnet-5-0#ignore-all-null-value-properties).
69
+
This would prevent unset properties on your digital twin or relationship from being included in the payload sent to the service.
0 commit comments