-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
592 additions
and
1,900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
sdk/iot/Azure.Iot.Hub.Service/src/ExportImportDeviceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using Azure.Iot.Hub.Service.Models; | ||
|
||
namespace Azure.Iot.Hub.Service | ||
{ | ||
/// <summary> | ||
/// Helper functions for mutating the <see cref="ExportImportDevice"/> instance. | ||
/// </summary> | ||
internal static class ExportImportDeviceExtensions | ||
{ | ||
/// <summary> | ||
/// Initializes the <see cref="ExportImportDevice.Tags"/> property using provided values. | ||
/// </summary> | ||
public static ExportImportDevice WithTags(this ExportImportDevice device, IDictionary<string, object> tags) | ||
{ | ||
foreach (var tag in tags) | ||
{ | ||
device.Tags.Add(tag); | ||
} | ||
return device; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the <see cref="ExportImportDevice.Properties"/> property using provided values. | ||
/// </summary> | ||
public static ExportImportDevice WithPropertiesFrom(this ExportImportDevice device, TwinProperties properties) | ||
{ | ||
|
||
var container = new PropertyContainer(); | ||
if (properties != null) | ||
{ | ||
foreach (var property in properties.Desired) | ||
{ | ||
container.Desired.Add(property); | ||
} | ||
foreach (var property in properties.Reported) | ||
{ | ||
container.Reported.Add(property); | ||
} | ||
} | ||
|
||
device.Properties = container; | ||
|
||
return device; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the <see cref="ExportImportDevice.ParentScopes"/> property using provided values. | ||
/// </summary> | ||
public static ExportImportDevice WithParentScopes(this ExportImportDevice device, IList<string> parentScopes) | ||
{ | ||
foreach (var parentScope in parentScopes) | ||
{ | ||
device.ParentScopes.Add(parentScope); | ||
} | ||
return device; | ||
} | ||
} | ||
} |
Oops, something went wrong.