示例#1
0
        internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element)
        {
            Optional <Bypass> bypass = default;
            Optional <IList <VirtualNetworkRule> > virtualNetworkRules = default;
            Optional <IList <IPRule> >             ipRules             = default;
            DefaultAction defaultAction = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    bypass = new Bypass(property.Value.GetString());
                    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;
                }
                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("defaultAction"))
                {
                    defaultAction = property.Value.GetString().ToDefaultAction();
                    continue;
                }
            }
            return(new NetworkRuleSet(Optional.ToNullable(bypass), Optional.ToList(virtualNetworkRules), Optional.ToList(ipRules), defaultAction));
        }
示例#2
0
        internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element)
        {
            Bypass?bypass = default;
            IList <VirtualNetworkRule> virtualNetworkRules = default;
            IList <IPRule>             ipRules             = default;
            DefaultAction defaultAction = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    bypass = new Bypass(property.Value.GetString());
                    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;
                }
                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("defaultAction"))
                {
                    defaultAction = property.Value.GetString().ToDefaultAction();
                    continue;
                }
            }
            return(new NetworkRuleSet(bypass, virtualNetworkRules, ipRules, defaultAction));
        }