Created
April 8, 2022 16:53
-
-
Save rido-min/d01ef6916b806d21fbc240c3a286be38 to your computer and use it in GitHub Desktop.
ModelsRepositoryClientExtensions
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); | |
List<string> modelDefinitions = new(); | |
foreach (var dtmi in dtmiStrings) | |
{ | |
ModelResult result = await client.GetModelAsync(dtmi, ModelDependencyResolution.Disabled); | |
modelDefinitions.Add(result.Content[dtmi]); | |
} | |
return modelDefinitions; | |
} | |
public static IEnumerable<string> ParserDtmiResolver(this ModelsRepositoryClient client, IReadOnlyCollection<Dtmi> dtmis) | |
{ | |
IEnumerable<string> dtmiStrings = dtmis.Select(s => s.AbsoluteUri); | |
List<string> modelDefinitions = new(); | |
foreach (var dtmi in dtmiStrings) | |
{ | |
ModelResult result = client.GetModel(dtmi, ModelDependencyResolution.Disabled); | |
modelDefinitions.Add(result.Content[dtmi]); | |
} | |
return modelDefinitions; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment