private async Task ProcessDeviceInfo(dynamic deviceInfo) { string versionAsString = ""; if (deviceInfo.Version != null) { dynamic version = deviceInfo.Version; versionAsString = version.ToString(); } switch (versionAsString) { case SampleDeviceFactory.VERSION_1_0: //Data coming in from the simulator can sometimes turn a boolean into 0 or 1. //Check the HubEnabledState since this is actually displayed and make sure it's in a good format DeviceSchemaHelper.FixDeviceSchema(deviceInfo); dynamic id = DeviceSchemaHelper.GetConnectionDeviceId(deviceInfo); string name = id.ToString(); Trace.TraceInformation("ProcessEventAsync -- DeviceInfo: {0}", name); await _deviceLogic.UpdateDeviceFromDeviceInfoPacketAsync(deviceInfo); break; default: Trace.TraceInformation("Unknown version {0} provided in Device Info packet", versionAsString); break; } }
private async Task ProcessDeviceInfo(DeviceModel deviceInfo) { string versionAsString = ""; if (deviceInfo.Version != null) { versionAsString = deviceInfo.Version; } switch (versionAsString) { case SampleDeviceFactory.VERSION_1_0: //Data coming in from the simulator can sometimes turn a boolean into 0 or 1. //Check the HubEnabledState since this is actually displayed and make sure it's in a good format //Should not be required for strongly typed object //DeviceSchemaHelperND.FixDeviceSchema(deviceInfo); if (deviceInfo.IoTHub == null) { throw new DeviceRequiredPropertyNotFoundException("'IoTHubProperties' property is missing"); } string name = deviceInfo.IoTHub.ConnectionDeviceId; Trace.TraceInformation("ProcessEventAsync -- DeviceInfo: {0}", name); await _deviceLogic.UpdateDeviceFromDeviceInfoPacketAsync(deviceInfo); // Pick the task object rather than using await, since there is no need to wait until cache updated var task = _deviceLogic.AddToNameCache(deviceInfo.DeviceProperties.DeviceID); break; default: Trace.TraceInformation("Unknown version {0} provided in Device Info packet", versionAsString); break; } }