Exemple #1
0
        internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element)
        {
            Optional <NetworkRuleBypassOptions>    bypass              = default;
            Optional <NetworkRuleAction>           defaultAction       = default;
            Optional <IList <IPRule> >             ipRules             = default;
            Optional <IList <VirtualNetworkRule> > virtualNetworkRules = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    bypass = new NetworkRuleBypassOptions(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("defaultAction"))
                {
                    defaultAction = new NetworkRuleAction(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ipRules"))
                {
                    List <IPRule> array = new List <IPRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(IPRule.DeserializeIPRule(item));
                    }
                    ipRules = array;
                    continue;
                }
                if (property.NameEquals("virtualNetworkRules"))
                {
                    List <VirtualNetworkRule> array = new List <VirtualNetworkRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VirtualNetworkRule.DeserializeVirtualNetworkRule(item));
                    }
                    virtualNetworkRules = array;
                    continue;
                }
            }
            return(new NetworkRuleSet(Optional.ToNullable(bypass), Optional.ToNullable(defaultAction), Optional.ToList(ipRules), Optional.ToList(virtualNetworkRules)));
        }
Exemple #2
0
        internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element)
        {
            NetworkRuleBypassOptions?  bypass              = default;
            NetworkRuleAction?         defaultAction       = default;
            IList <IPRule>             ipRules             = default;
            IList <VirtualNetworkRule> virtualNetworkRules = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    bypass = new NetworkRuleBypassOptions(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("defaultAction"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    defaultAction = new NetworkRuleAction(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ipRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <IPRule> array = new List <IPRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(IPRule.DeserializeIPRule(item));
                        }
                    }
                    ipRules = array;
                    continue;
                }
                if (property.NameEquals("virtualNetworkRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <VirtualNetworkRule> array = new List <VirtualNetworkRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(VirtualNetworkRule.DeserializeVirtualNetworkRule(item));
                        }
                    }
                    virtualNetworkRules = array;
                    continue;
                }
            }
            return(new NetworkRuleSet(bypass, defaultAction, ipRules, virtualNetworkRules));
        }
        internal static MhsmNetworkRuleSet DeserializeMhsmNetworkRuleSet(JsonElement element)
        {
            Optional <NetworkRuleBypassOptions>     bypass              = default;
            Optional <NetworkRuleAction>            defaultAction       = default;
            Optional <IList <MhsmipRule> >          ipRules             = default;
            Optional <IList <WritableSubResource> > virtualNetworkRules = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    bypass = new NetworkRuleBypassOptions(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("defaultAction"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    defaultAction = new NetworkRuleAction(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ipRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MhsmipRule> array = new List <MhsmipRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MhsmipRule.DeserializeMhsmipRule(item));
                    }
                    ipRules = array;
                    continue;
                }
                if (property.NameEquals("virtualNetworkRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WritableSubResource> array = new List <WritableSubResource>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString()));
                    }
                    virtualNetworkRules = array;
                    continue;
                }
            }
            return(new MhsmNetworkRuleSet(Optional.ToNullable(bypass), Optional.ToNullable(defaultAction), Optional.ToList(ipRules), Optional.ToList(virtualNetworkRules)));
        }