Ejemplo n.º 1
0
        internal static IotHubDeviceCreatedEventData DeserializeIotHubDeviceCreatedEventData(JsonElement element)
        {
            Optional <string>         deviceId = default;
            Optional <string>         hubName  = default;
            Optional <DeviceTwinInfo> twin     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("deviceId"))
                {
                    deviceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hubName"))
                {
                    hubName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("twin"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    twin = DeviceTwinInfo.DeserializeDeviceTwinInfo(property.Value);
                    continue;
                }
            }
            return(new IotHubDeviceCreatedEventData(deviceId.Value, hubName.Value, twin.Value));
        }
        internal static DeviceLifeCycleEventProperties DeserializeDeviceLifeCycleEventProperties(JsonElement element)
        {
            Optional <string>         deviceId = default;
            Optional <string>         hubName  = default;
            Optional <DeviceTwinInfo> twin     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("deviceId"))
                {
                    deviceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hubName"))
                {
                    hubName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("twin"))
                {
                    twin = DeviceTwinInfo.DeserializeDeviceTwinInfo(property.Value);
                    continue;
                }
            }
            return(new DeviceLifeCycleEventProperties(deviceId.Value, hubName.Value, twin.Value));
        }