internal static PacketCaptureResult DeserializePacketCaptureResult(JsonElement element)
        {
            string name   = default;
            string id     = default;
            string etag   = default;
            string target = default;
            int?   bytesToCapturePerPacket = default;
            int?   totalBytesPerSession    = default;
            int?   timeLimitInSeconds      = default;
            PacketCaptureStorageLocation        storageLocation = default;
            IReadOnlyList <PacketCaptureFilter> filters         = default;
            ProvisioningState?provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("target"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            target = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("bytesToCapturePerPacket"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            bytesToCapturePerPacket = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("totalBytesPerSession"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            totalBytesPerSession = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("timeLimitInSeconds"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            timeLimitInSeconds = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("storageLocation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            storageLocation = PacketCaptureStorageLocation.DeserializePacketCaptureStorageLocation(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("filters"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <PacketCaptureFilter> array = new List <PacketCaptureFilter>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(PacketCaptureFilter.DeserializePacketCaptureFilter(item));
                                }
                            }
                            filters = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PacketCaptureResult(name, id, etag, target, bytesToCapturePerPacket, totalBytesPerSession, timeLimitInSeconds, storageLocation, filters, provisioningState));
        }
        internal static PacketCaptureParameters DeserializePacketCaptureParameters(JsonElement element)
        {
            string target = default;
            int?   bytesToCapturePerPacket = default;
            int?   totalBytesPerSession    = default;
            int?   timeLimitInSeconds      = default;
            PacketCaptureStorageLocation storageLocation = default;
            IList <PacketCaptureFilter>  filters         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("target"))
                {
                    target = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("bytesToCapturePerPacket"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    bytesToCapturePerPacket = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("totalBytesPerSession"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    totalBytesPerSession = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("timeLimitInSeconds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    timeLimitInSeconds = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("storageLocation"))
                {
                    storageLocation = PacketCaptureStorageLocation.DeserializePacketCaptureStorageLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("filters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PacketCaptureFilter> array = new List <PacketCaptureFilter>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PacketCaptureFilter.DeserializePacketCaptureFilter(item));
                        }
                    }
                    filters = array;
                    continue;
                }
            }
            return(new PacketCaptureParameters(target, bytesToCapturePerPacket, totalBytesPerSession, timeLimitInSeconds, storageLocation, filters));
        }
コード例 #3
0
        internal static PacketCaptureResult DeserializePacketCaptureResult(JsonElement element)
        {
            Optional <string> name   = default;
            Optional <string> id     = default;
            Optional <string> etag   = default;
            Optional <string> target = default;
            Optional <int>    bytesToCapturePerPacket = default;
            Optional <int>    totalBytesPerSession    = default;
            Optional <int>    timeLimitInSeconds      = default;
            Optional <PacketCaptureStorageLocation>         storageLocation = default;
            Optional <IReadOnlyList <PacketCaptureFilter> > filters         = default;
            Optional <ProvisioningState> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("target"))
                        {
                            target = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("bytesToCapturePerPacket"))
                        {
                            bytesToCapturePerPacket = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("totalBytesPerSession"))
                        {
                            totalBytesPerSession = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("timeLimitInSeconds"))
                        {
                            timeLimitInSeconds = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("storageLocation"))
                        {
                            storageLocation = PacketCaptureStorageLocation.DeserializePacketCaptureStorageLocation(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("filters"))
                        {
                            List <PacketCaptureFilter> array = new List <PacketCaptureFilter>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PacketCaptureFilter.DeserializePacketCaptureFilter(item));
                            }
                            filters = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PacketCaptureResult(name.Value, id.Value, etag.Value, target.Value, Optional.ToNullable(bytesToCapturePerPacket), Optional.ToNullable(totalBytesPerSession), Optional.ToNullable(timeLimitInSeconds), storageLocation.Value, Optional.ToList(filters), Optional.ToNullable(provisioningState)));
        }