Beispiel #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)));
        }
Beispiel #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));
        }