/// <summary> /// Read from the twin for the given flatten name /// </summary> /// <param name="twin">The source twin</param> /// <param name="flatName">The flat name, e.g. tags.city or properties.desired.TTL</param> /// <returns>The tag/property value</returns> static public dynamic Get(this Twin twin, string flatName) { // Remove the common prefix "twin." flatName = flatName.TryTrimPrefix(PREFIX_TWIN); // "deviceId" is a built-in property of the twin if (flatName == DEVICEID) { return(twin.DeviceId); } // Pick the selector according to prefix of the flat name, then get the value string name; foreach (var selector in _selectors) { if (flatName.TryTrimPrefix(selector.Key, out name)) { var collection = selector.Value(twin); return(TwinCollectionExtension.Get(collection, name)); } } return(null); }