public static void AddComponentProperty(this TwinCollection collection, string componentName, string propertyName, object propertyValue) { JObject componentJson = collection.GetOrCreateComponent(componentName); if (!componentJson.ContainsKey(propertyName)) { componentJson[propertyName] = JToken.FromObject(propertyValue); } }
public void InitComponent() { TwinCollection collection = new TwinCollection(); collection.GetOrCreateComponent("myComp"); Assert.True(collection.Contains("myComp")); var comp = collection["myComp"] as JObject; Assert.True(comp.ContainsKey("__t")); }