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
using System.Net.Security; | |
using System.Net.Sockets; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
string host = "test.mosquitto.org"; | |
int port = 8883; | |
using Socket socket = new(SocketType.Stream, ProtocolType.Tcp); | |
socket.Connect(host, port); | |
using NetworkStream stream = new(socket); |
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
Copyright 2020 Christopher Lawlor | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O |
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
using Microsoft.Azure.Devices; | |
using System.Text.Json; | |
namespace SampleDtdlCmd | |
{ | |
public class Command<TReq, TResp> | |
{ | |
string _cs; | |
string _did; | |
string _name; |
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
# Copyright 2017 The Kubernetes Authors. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
internal static string ComputeDeviceKey(string masterKey, string deviceId) => | |
Convert.ToBase64String(new System.Security.Cryptography.HMACSHA256(Convert.FromBase64String(masterKey)).ComputeHash(System.Text.Encoding.UTF8.GetBytes(deviceId))); |
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
namespace DTDL_scratch | |
{ | |
using Azure.IoT.ModelsRepository; | |
using Microsoft.Azure.DigitalTwins.Parser; | |
internal static class ModelsRepositoryClientExtensions | |
{ | |
public static async Task<IEnumerable<string>> ParserDtmiResolverAsync(this ModelsRepositoryClient client, IReadOnlyCollection<Dtmi> dtmis) | |
{ | |
IEnumerable<string> dtmiStrings = dtmis.Select(s => s.AbsoluteUri); |
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
using Microsoft.Azure.DigitalTwins.Parser; | |
using Microsoft.Azure.DigitalTwins.Parser.Models; | |
using System.Text.Json; | |
string basePath = Path.Join(System.Reflection.Assembly.GetExecutingAssembly().Location + @"./../../../"); | |
string ReadFile(string path) => File.ReadAllText(Path.Join(basePath, path)); | |
string ToJs(object obj) => JsonSerializer.Serialize(obj); | |
var objectModel = new ModelParser().Parse(new string[] { ReadFile("geotypes-1.json") }); |
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
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 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 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> |
NewerOlder