public void EnumerateComponents_TwoElements() { string json = @" { telemetryInterval :1, tempSensor1: { __t: 'c', targetTemperature: { value : 1.8 } }, tempSensor2: { __t: 'c', targetTemperature: { value : 1.8 } }, aComplexProp : { name: 'rido', age: 33 } }"; TwinCollection twinCollection = new TwinCollection(json); var compNames = twinCollection.EnumerateComponents(); Assert.Equal(2, compNames.Count); Assert.Equal("tempSensor2", compNames[1]); }
private static Task DesiredPropertyUpdateCallback(TwinCollection desiredProperties, object userContext) { //desired event should be fired for a single, so first, component. var componentName = desiredProperties.EnumerateComponents().FirstOrDefault();; var comp = desiredPropertyCallbacks[componentName]; comp?.Invoke(desiredProperties); return(Task.FromResult(0)); }
private Task DesiredPropertyUpdateCallback(TwinCollection desiredProperties, object userContext) { var comps = desiredProperties.EnumerateComponents(); foreach (var c in comps) { var ccb = desiredPropertyCallbacks[c]; ccb?.Invoke(desiredProperties); } return(Task.FromResult(0)); }
public void EnumerateComponents_OneElement() { string json = @" { tempSensor1: { __t: 'c', targetTemperature: { value : 1.8 } } }"; TwinCollection twinCollection = new TwinCollection(json); var compNames = twinCollection.EnumerateComponents(); Assert.Single(compNames, "tempSensor1"); }