Esempio n. 1
0
 internal MatchCondition(WafMatchVariable matchVariable, string selector, MatchOperator matchOperator, bool?negateCondition, IList <string> matchValue, IList <TransformType> transforms)
 {
     MatchVariable   = matchVariable;
     Selector        = selector;
     MatchOperator   = matchOperator;
     NegateCondition = negateCondition;
     MatchValue      = matchValue;
     Transforms      = transforms;
 }
Esempio n. 2
0
        public MatchCondition(WafMatchVariable matchVariable, MatchOperator matchOperator, IEnumerable <string> matchValue)
        {
            if (matchValue == null)
            {
                throw new ArgumentNullException(nameof(matchValue));
            }

            MatchVariable = matchVariable;
            MatchOperator = matchOperator;
            MatchValue    = matchValue.ToList();
            Transforms    = new ChangeTrackingList <TransformType>();
        }
Esempio n. 3
0
        internal static MatchCondition DeserializeMatchCondition(JsonElement element)
        {
            WafMatchVariable  matchVariable              = default;
            Optional <string> selector                   = default;
            MatchOperator     @operator                  = default;
            Optional <bool>   negateCondition            = default;
            IList <string>    matchValue                 = default;
            Optional <IList <TransformType> > transforms = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("matchVariable"))
                {
                    matchVariable = new WafMatchVariable(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("selector"))
                {
                    selector = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("operator"))
                {
                    @operator = new MatchOperator(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("negateCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    negateCondition = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("matchValue"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    matchValue = array;
                    continue;
                }
                if (property.NameEquals("transforms"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TransformType> array = new List <TransformType>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new TransformType(item.GetString()));
                    }
                    transforms = array;
                    continue;
                }
            }
            return(new MatchCondition(matchVariable, selector.Value, @operator, Optional.ToNullable(negateCondition), matchValue, Optional.ToList(transforms)));
        }