示例#1
0
 internal WebApplicationFirewallCustomRule(string name, ETag?etag, int priority, WebApplicationFirewallRuleType ruleType, IList <MatchCondition> matchConditions, WebApplicationFirewallAction action)
 {
     Name            = name;
     Etag            = etag;
     Priority        = priority;
     RuleType        = ruleType;
     MatchConditions = matchConditions;
     Action          = action;
 }
示例#2
0
        internal static WebApplicationFirewallCustomRule DeserializeWebApplicationFirewallCustomRule(JsonElement element)
        {
            Optional <string> name = default;
            Optional <ETag>   etag = default;
            int priority           = default;
            WebApplicationFirewallRuleType ruleType        = default;
            IList <MatchCondition>         matchConditions = default;
            WebApplicationFirewallAction   action          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    etag = new ETag(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("priority"))
                {
                    priority = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new WebApplicationFirewallRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("matchConditions"))
                {
                    List <MatchCondition> array = new List <MatchCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MatchCondition.DeserializeMatchCondition(item));
                    }
                    matchConditions = array;
                    continue;
                }
                if (property.NameEquals("action"))
                {
                    action = new WebApplicationFirewallAction(property.Value.GetString());
                    continue;
                }
            }
            return(new WebApplicationFirewallCustomRule(name.Value, Optional.ToNullable(etag), priority, ruleType, matchConditions, action));
        }
示例#3
0
        public WebApplicationFirewallCustomRule(int priority, WebApplicationFirewallRuleType ruleType, IEnumerable <MatchCondition> matchConditions, WebApplicationFirewallAction action)
        {
            if (matchConditions == null)
            {
                throw new ArgumentNullException(nameof(matchConditions));
            }

            Priority        = priority;
            RuleType        = ruleType;
            MatchConditions = matchConditions.ToList();
            Action          = action;
        }
        internal static WebApplicationFirewallCustomRule DeserializeWebApplicationFirewallCustomRule(JsonElement element)
        {
            string name     = default;
            string etag     = default;
            int    priority = default;
            WebApplicationFirewallRuleType ruleType        = default;
            IList <MatchCondition>         matchConditions = default;
            WebApplicationFirewallAction   action          = 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("priority"))
                {
                    priority = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("ruleType"))
                {
                    ruleType = new WebApplicationFirewallRuleType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("matchConditions"))
                {
                    List <MatchCondition> array = new List <MatchCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(MatchCondition.DeserializeMatchCondition(item));
                        }
                    }
                    matchConditions = array;
                    continue;
                }
                if (property.NameEquals("action"))
                {
                    action = new WebApplicationFirewallAction(property.Value.GetString());
                    continue;
                }
            }
            return(new WebApplicationFirewallCustomRule(name, etag, priority, ruleType, matchConditions, action));
        }