public static dtdlInterfaceModel GetDTDLModel(DigitalTwinsClient client, string dtmi) { dtdlInterfaceModel dtdlModel = new dtdlInterfaceModel(); try { Response <ModelData> r = client.GetModel(dtmi); if (r.Value != null) { if (!Program.gVehicle.Exists(item => item.id == dtmi)) { dtdlModel = DigitalTwinInMemory.LoadInterfaceModel(r.Value.Model); } } } catch (RequestFailedException e) { Console.WriteLine($"Response {e.Status}: {e.Message}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } return(dtdlModel); }
public static async Task GetModel(DigitalTwinsClient client) { Console.Write("modelId (dtmi): "); string dtmi = Console.ReadLine(); try { Response <ModelData> r = await client.GetModelAsync(dtmi); if (r.Value != null) { if (!Program.gVehicle.Exists(item => item.id == dtmi)) { dtdlInterfaceModel dtdlModel = DigitalTwinInMemory.LoadInterfaceModel(r.Value.Model); Program.gVehicle.Add(dtdlModel); } Console.WriteLine(Program.PrettifyJson(r.Value.Model)); } } catch (RequestFailedException e) { Console.WriteLine($"Response {e.Status}: {e.Message}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }