Skip to content
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

fix(samples):remove unnecessary lines from sample #12606

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public async Task RunSamplesAsync(DigitalTwinsClient client)
"Component1",
new ModelProperties
{
Metadata = { },
// component properties
CustomProperties =
{
Expand Down Expand Up @@ -118,12 +117,11 @@ public async Task RunSamplesAsync(DigitalTwinsClient client)
var customTwin = new CustomDigitalTwin
{
Id = customDtId,
Metadata = new CustomDigitalTwinMetadata { ModelId = modelId },
Metadata = { ModelId = modelId },
Prop1 = "Prop1 val",
Prop2 = 987,
Component1 = new Component1
{
Metadata = new Component1Metadata { },
ComponentProp1 = "Component prop1 val",
ComponentProp2 = 123,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class CustomDigitalTwin
public string ETag { get; set; }

[JsonPropertyName("$metadata")]
public CustomDigitalTwinMetadata Metadata { get; set; }
public CustomDigitalTwinMetadata Metadata { get; set; } = new CustomDigitalTwinMetadata();

[JsonPropertyName("Prop1")]
public string Prop1 { get; set; }
Expand All @@ -34,7 +34,7 @@ internal class CustomDigitalTwin
internal class Component1
{
[JsonPropertyName("$metadata")]
public Component1Metadata Metadata { get; set; }
public Component1Metadata Metadata { get; set; } = new Component1Metadata();

[JsonPropertyName("ComponentProp1")]
public string ComponentProp1 { get; set; }
Expand Down
7 changes: 2 additions & 5 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ var basicTwin = new BasicDigitalTwin
"Component1",
new ModelProperties
{
Metadata = { },
// component properties
CustomProperties =
{
Expand All @@ -164,12 +163,11 @@ You can review the [CustomDigitalTwin definition](https://github.com/Azure/azure
var customTwin = new CustomDigitalTwin
{
Id = customDtId,
Metadata = new CustomDigitalTwinMetadata { ModelId = modelId },
Metadata = { ModelId = modelId },
Prop1 = "Prop1 val",
Prop2 = 987,
Component1 = new Component1
{
Metadata = new Component1Metadata { },
ComponentProp1 = "Component prop1 val",
ComponentProp2 = 123,
}
Expand Down Expand Up @@ -212,12 +210,11 @@ Custom types provide the best possible experience.
var customTwin = new CustomDigitalTwin
{
Id = customDtId,
Metadata = new CustomDigitalTwinMetadata { ModelId = modelId },
Metadata = { ModelId = modelId },
Prop1 = "Prop1 val",
Prop2 = 987,
Component1 = new Component1
{
Metadata = new Component1Metadata { },
ComponentProp1 = "Component prop1 val",
ComponentProp2 = 123,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ public virtual Response<string> GetDigitalTwin(string digitalTwinId, Cancellatio
/// var customTwin = new CustomDigitalTwin
/// {
/// Id = customDtId,
/// Metadata = new CustomDigitalTwinMetadata { ModelId = modelId },
/// Metadata = { ModelId = modelId },
/// Prop1 = &quot;Prop1 val&quot;,
/// Prop2 = 987,
/// Component1 = new Component1
/// {
/// Metadata = new Component1Metadata { },
/// ComponentProp1 = &quot;Component prop1 val&quot;,
/// ComponentProp2 = 123,
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Azure.DigitalTwins.Core.Serialization
/// &quot;Component1&quot;,
/// new ModelProperties
/// {
/// Metadata = { },
/// // component properties
/// CustomProperties =
/// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ModelProperties
/// Information about the model a component conforms to. This field is present on every digital twin.
/// </summary>
[JsonPropertyName("$metadata")]
public ComponentMetadata Metadata { get; } = new ComponentMetadata();
public ComponentMetadata Metadata { get; internal set; } = new ComponentMetadata();

/// <summary>
/// Additional properties of the digital twin. This field will contain any properties of the digital twin that are not already defined by the other strong types of this class.
Expand Down