Exemplo n.º 1
0
        internal static ConnectivityHop DeserializeConnectivityHop(JsonElement element)
        {
            Optional <string> type       = default;
            Optional <string> id         = default;
            Optional <string> address    = default;
            Optional <string> resourceId = default;
            Optional <IReadOnlyList <string> >            nextHopIds = default;
            Optional <IReadOnlyList <ConnectivityIssue> > issues     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("address"))
                {
                    address = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("nextHopIds"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    nextHopIds = array;
                    continue;
                }
                if (property.NameEquals("issues"))
                {
                    List <ConnectivityIssue> array = new List <ConnectivityIssue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConnectivityIssue.DeserializeConnectivityIssue(item));
                    }
                    issues = array;
                    continue;
                }
            }
            return(new ConnectivityHop(type.Value, id.Value, address.Value, resourceId.Value, Optional.ToList(nextHopIds), Optional.ToList(issues)));
        }
        internal static ConnectivityHop DeserializeConnectivityHop(JsonElement element)
        {
            string type       = default;
            string id         = default;
            string address    = default;
            string resourceId = default;
            IReadOnlyList <string>            nextHopIds = default;
            IReadOnlyList <ConnectivityIssue> issues     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("address"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    address = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("nextHopIds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    nextHopIds = array;
                    continue;
                }
                if (property.NameEquals("issues"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectivityIssue> array = new List <ConnectivityIssue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectivityIssue.DeserializeConnectivityIssue(item));
                        }
                    }
                    issues = array;
                    continue;
                }
            }
            return(new ConnectivityHop(type, id, address, resourceId, nextHopIds, issues));
        }
Exemplo n.º 3
0
        internal static HopLink DeserializeHopLink(JsonElement element)
        {
            Optional <string> nextHopId = default;
            Optional <string> linkType  = default;
            Optional <IReadOnlyList <ConnectivityIssue> >    issues  = default;
            Optional <IReadOnlyDictionary <string, string> > context = default;
            Optional <string> resourceId       = default;
            Optional <long>   roundTripTimeMin = default;
            Optional <long>   roundTripTimeAvg = default;
            Optional <long>   roundTripTimeMax = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("nextHopId"))
                {
                    nextHopId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("linkType"))
                {
                    linkType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("issues"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ConnectivityIssue> array = new List <ConnectivityIssue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConnectivityIssue.DeserializeConnectivityIssue(item));
                    }
                    issues = array;
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    context = dictionary;
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("roundTripTimeMin"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            roundTripTimeMin = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("roundTripTimeAvg"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            roundTripTimeAvg = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("roundTripTimeMax"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            roundTripTimeMax = property0.Value.GetInt64();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new HopLink(nextHopId.Value, linkType.Value, Optional.ToList(issues), Optional.ToDictionary(context), resourceId.Value, Optional.ToNullable(roundTripTimeMin), Optional.ToNullable(roundTripTimeAvg), Optional.ToNullable(roundTripTimeMax)));
        }
Exemplo n.º 4
0
        internal static ConnectivityHop DeserializeConnectivityHop(JsonElement element)
        {
            Optional <string> type       = default;
            Optional <string> address    = default;
            Optional <string> resourceId = default;
            Optional <IReadOnlyList <string> >            nextHopIds     = default;
            Optional <IReadOnlyList <string> >            previousHopIds = default;
            Optional <IReadOnlyList <HopLink> >           links          = default;
            Optional <IReadOnlyList <HopLink> >           previousLinks  = default;
            Optional <IReadOnlyList <ConnectivityIssue> > issues         = default;
            ResourceIdentifier id = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("address"))
                {
                    address = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("nextHopIds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    nextHopIds = array;
                    continue;
                }
                if (property.NameEquals("previousHopIds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    previousHopIds = array;
                    continue;
                }
                if (property.NameEquals("links"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <HopLink> array = new List <HopLink>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HopLink.DeserializeHopLink(item));
                    }
                    links = array;
                    continue;
                }
                if (property.NameEquals("previousLinks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <HopLink> array = new List <HopLink>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HopLink.DeserializeHopLink(item));
                    }
                    previousLinks = array;
                    continue;
                }
                if (property.NameEquals("issues"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ConnectivityIssue> array = new List <ConnectivityIssue>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConnectivityIssue.DeserializeConnectivityIssue(item));
                    }
                    issues = array;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
            }
            return(new ConnectivityHop(id, type.Value, address.Value, resourceId.Value, Optional.ToList(nextHopIds), Optional.ToList(previousHopIds), Optional.ToList(links), Optional.ToList(previousLinks), Optional.ToList(issues)));
        }