Skip to content

Commit

Permalink
fix(samples):remove unnecessary lines from sample (#12606)
Browse files Browse the repository at this point in the history
  • Loading branch information
Basel Rustum authored Jun 8, 2020
1 parent 5800dc1 commit 12df3e5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
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

0 comments on commit 12df3e5

Please sign in to comment.