/// <summary> /// Creates a <c>LeafExpression</c> capable of evaluating JSON using the operator specified in the JSON rule. /// </summary> /// <returns>The LeafExpression.</returns> public override Expression ToExpression() { 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); } else if (this.Is != null || this.NotEquals != null) { leafOperator = new EqualsOperator( specifiedValue: this.Is ?? this.NotEquals, isNegative: this.NotEquals != null); } if (leafOperator != null) { return(new LeafExpression(this.ResourceType, this.Path, leafOperator)); } throw new NotImplementedException(); }
/// <summary> /// Creates a LeafExpression. /// </summary> /// <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(string resourceType, string path, LeafExpressionOperator @operator) { this.ResourceType = resourceType; this.Path = path ?? throw new ArgumentNullException(nameof(path)); this.Operator = @operator ?? throw new ArgumentNullException(nameof(@operator)); }