Example #1
0
        internal static ConnectionMonitorQueryResult DeserializeConnectionMonitorQueryResult(JsonElement element)
        {
            Optional <ConnectionMonitorSourceStatus>            sourceStatus = default;
            Optional <IReadOnlyList <ConnectionStateSnapshot> > states       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sourceStatus"))
                {
                    sourceStatus = new ConnectionMonitorSourceStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("states"))
                {
                    List <ConnectionStateSnapshot> array = new List <ConnectionStateSnapshot>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConnectionStateSnapshot.DeserializeConnectionStateSnapshot(item));
                    }
                    states = array;
                    continue;
                }
            }
            return(new ConnectionMonitorQueryResult(Optional.ToNullable(sourceStatus), Optional.ToList(states)));
        }
        internal static ConnectionMonitorQueryResult DeserializeConnectionMonitorQueryResult(JsonElement element)
        {
            ConnectionMonitorSourceStatus?          sourceStatus = default;
            IReadOnlyList <ConnectionStateSnapshot> states       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sourceStatus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    sourceStatus = new ConnectionMonitorSourceStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("states"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectionStateSnapshot> array = new List <ConnectionStateSnapshot>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectionStateSnapshot.DeserializeConnectionStateSnapshot(item));
                        }
                    }
                    states = array;
                    continue;
                }
            }
            return(new ConnectionMonitorQueryResult(sourceStatus, states));
        }