internal static OutboundRule DeserializeOutboundRule(JsonElement element)
        {
            string name = default;
            string etag = default;
            string type = default;
            string id   = default;
            int?   allocatedOutboundPorts = default;
            IList <SubResource> frontendIPConfigurations = default;
            SubResource         backendAddressPool       = default;
            ProvisioningState?  provisioningState        = default;
            LoadBalancerOutboundRuleProtocol?protocol    = default;
            bool?enableTcpReset       = default;
            int? idleTimeoutInMinutes = 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("etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    etag = property.Value.GetString();
                    continue;
                }
                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("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("allocatedOutboundPorts"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            allocatedOutboundPorts = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("frontendIPConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <SubResource> array = new List <SubResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(DeserializeSubResource(item));
                                }
                            }
                            frontendIPConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("backendAddressPool"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            backendAddressPool = DeserializeSubResource(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("protocol"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            protocol = new LoadBalancerOutboundRuleProtocol(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("enableTcpReset"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            enableTcpReset = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("idleTimeoutInMinutes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            idleTimeoutInMinutes = property0.Value.GetInt32();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new OutboundRule(id, name, etag, type, allocatedOutboundPorts, frontendIPConfigurations, backendAddressPool, provisioningState, protocol, enableTcpReset, idleTimeoutInMinutes));
        }
Example #2
0
        internal static OutboundRule DeserializeOutboundRule(JsonElement element)
        {
            Optional <string> name = default;
            Optional <string> etag = default;
            Optional <string> type = default;
            Optional <string> id   = default;
            Optional <int>    allocatedOutboundPorts = default;
            Optional <IList <SubResource> >             frontendIPConfigurations = default;
            Optional <SubResource>                      backendAddressPool       = default;
            Optional <ProvisioningState>                provisioningState        = default;
            Optional <LoadBalancerOutboundRuleProtocol> protocol = default;
            Optional <bool> enableTcpReset       = default;
            Optional <int>  idleTimeoutInMinutes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("allocatedOutboundPorts"))
                        {
                            allocatedOutboundPorts = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("frontendIPConfigurations"))
                        {
                            List <SubResource> array = new List <SubResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(DeserializeSubResource(item));
                            }
                            frontendIPConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("backendAddressPool"))
                        {
                            backendAddressPool = DeserializeSubResource(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("protocol"))
                        {
                            protocol = new LoadBalancerOutboundRuleProtocol(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("enableTcpReset"))
                        {
                            enableTcpReset = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("idleTimeoutInMinutes"))
                        {
                            idleTimeoutInMinutes = property0.Value.GetInt32();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new OutboundRule(id.Value, name.Value, etag.Value, type.Value, Optional.ToNullable(allocatedOutboundPorts), Optional.ToList(frontendIPConfigurations), backendAddressPool.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(protocol), Optional.ToNullable(enableTcpReset), Optional.ToNullable(idleTimeoutInMinutes)));
        }