Beispiel #1
0
        /// <summary>
        /// Creates a <c>LeafExpression</c> capable of evaluating JSON using the operator specified in the JSON rule.
        /// </summary>
        /// <param name="rootRule">The JSON rule this leaf expression is part of.</param>
        /// <returns>The LeafExpression.</returns>
        public override Expression ToExpression(RuleDefinition rootRule)
        {
            LeafExpressionOperator leafOperator = null;

            if (this.Exists != null)
            {
                leafOperator = new ExistsOperator(Exists.Value, isNegative: false);
            }
            else if (this.HasValue != null)
            {
                leafOperator = new HasValueOperator(HasValue.Value, isNegative: false);
            }

            if (leafOperator != null)
            {
                return(new LeafExpression(rootRule, this.ResourceType, this.Path, leafOperator));
            }

            throw new NotImplementedException();
        }
Beispiel #2
0
 /// <summary>
 /// Creates a LeafExpression.
 /// </summary>
 /// <param name="rootRule">The parent <c>RuleDefinition</c>.</param>
 /// <param name="resourceType">The resource type this expression evaluates.</param>
 /// <param name="path">The JSON path being evaluated.</param>
 /// <param name="operator">The operator used to evaluate the resource type and/or path.</param>
 public LeafExpression(RuleDefinition rootRule, string resourceType, string path, LeafExpressionOperator @operator)
     : base(rootRule)
 {
     (this.ResourceType, this.Path, this.Operator) = (resourceType, path, @operator ?? throw new ArgumentNullException(nameof(@operator)));
 }