public void ClientDemo() { var client = new DigitalTwinsClient(); DigitalTwin twin = client.GetTwin(); // creates DigitalTwin instance and stores the JSON payload in it, i.e. very cheap string json = twin.ToString(); // gets the origin JSON payload. Assert.IsTrue(ReferenceEquals(s_demo_payload, json)); // the payload is really the same string as was passed into DigitalTwin ctor Assert.AreEqual("ID0001", twin.Id); // this is where the JSON string is parsed (lazily) Assert.AreEqual(123, twin.CreatedAt); Assert.AreEqual(true, twin.Decomissioned); // Temperature and Unit are not on DigitaTwin (they are user defined properties), so let's use dynamic APIs. dynamic dynamic = twin; Assert.AreEqual(72, dynamic.Temperature); Assert.AreEqual("F", dynamic.Unit); Assert.AreEqual(123, dynamic.CreatedAt); // the service defined properties are also avaliable through dynamic calls. // the client also has strongly typed APIs TemperatureSensor sensor = client.GetTwin <TemperatureSensor>(); Assert.AreEqual("F", sensor.Unit); Assert.AreEqual(72, sensor.Temperature); Assert.AreEqual("ID0001", sensor.Id); Assert.AreEqual(123, sensor.CreatedAt); Assert.AreEqual(true, sensor.Decomissioned); // Interestingly, the base twin type can be converted to user defined type sensor = twin.As <TemperatureSensor>(); Assert.AreEqual("F", sensor.Unit); Assert.AreEqual(72, sensor.Temperature); Assert.AreEqual("ID0001", sensor.Id); Assert.AreEqual(123, sensor.CreatedAt); Assert.AreEqual(true, sensor.Decomissioned); }