This PoC shows how to use a base interface to describe the capabilities needed to implement self describing devices
This file contains hidden or 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
| namespace dtdl_dotnet | |
| { | |
| using Microsoft.Azure.DigitalTwins.Parser; | |
| using Microsoft.Azure.DigitalTwins.Parser.Models; | |
| public static class DtmiExtensions | |
| { | |
| public static string ToPath(this Dtmi dtmi) => $"{dtmi.ToString().ToLowerInvariant().Replace(":", "/").Replace(";", "-")}.json"; | |
| } | |
| public static class ModelParserExtensions |
This file contains hidden or 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
| Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.Empty.ToString("N"))) |
This file contains hidden or 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
| <Project> | |
| <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | |
| <PropertyGroup> | |
| <TargetFramework>netstandard1.0</TargetFramework> | |
| <IsPackable>true</IsPackable> | |
| <IncludeBuildOutput>false</IncludeBuildOutput> | |
| <ContentTargetFolders>contentFiles</ContentTargetFolders> | |
| <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> |
This file contains hidden or 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
| // https://stackoverflow.com/questions/58138793/system-text-json-jsonelement-toobject-workaround | |
| // https://stackoverflow.com/questions/61553962/getting-nested-properties-with-system-text-json | |
| static class JsonExtensions | |
| { | |
| public static JsonElement GetJsonElement(this JsonElement jsonElement, string path) | |
| { | |
| if (jsonElement.ValueKind is JsonValueKind.Null or JsonValueKind.Undefined) | |
| return default; | |
| string[] segments = path.Split('.', StringSplitOptions.RemoveEmptyEntries); |
This file contains hidden or 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
| { | |
| "@context": "dtmi:dtdl:context;2", | |
| "@id": "dtmi:rido:maps;1", | |
| "@type": "Interface", | |
| "displayName": "maps", | |
| "contents": [ | |
| { | |
| "@type": "Property", | |
| "writable": true, | |
| "name": "networkConfig", |
This file contains hidden or 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
| using Microsoft.Azure.Devices.Client; | |
| using Microsoft.Azure.Devices.Shared; | |
| using Newtonsoft.Json; | |
| using Newtonsoft.Json.Linq; | |
| using System; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace STS.Device | |
| { |
This file contains hidden or 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
| gci -r dtmi/**/*.json | foreach { dmr-client validate -m $_.FullName --strict --repo . --debug } |
This file contains hidden or 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
| using Microsoft.Azure.DigitalTwins.Parser; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Net.Http; | |
| using System.Threading.Tasks; | |
| namespace ResolutionSample | |
| { | |
| class Resolver | |
| { |
This file contains hidden or 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
| using Microsoft.Azure.Devices; | |
| using Microsoft.Azure.Devices.Client; | |
| using Microsoft.Azure.Devices.Serialization; | |
| using Microsoft.Azure.Devices.Shared; | |
| using Newtonsoft.Json; | |
| using System; | |
| using System.Threading.Tasks; | |
| namespace rido_learn_WritableProperties | |
| { |