public override void Select(DynamicResources resources,
                             IValue root,
                             JsonLocationNode lastNode,
                             IValue current,
                             INodeReceiver receiver,
                             ProcessingFlags options,
                             int depth)
 {
     if (current.ValueKind == JsonValueKind.Object)
     {
         IValue value;
         if (current.TryGetProperty(_identifier, out value))
         {
             this.TailSelect(resources, root,
                             PathGenerator.Generate(lastNode, _identifier, options),
                             value, receiver, options, depth);
         }
     }
 }
 public override void Select(DynamicResources resources,
                             IValue root,
                             JsonLocationNode lastNode,
                             IValue current,
                             INodeReceiver receiver,
                             ProcessingFlags options,
                             int depth)
 {
     if (current.ValueKind == JsonValueKind.Array)
     {
         Int32 index = 0;
         foreach (var item in current.EnumerateArray())
         {
             IValue val;
             if (_expr.TryEvaluate(resources, root, item, options, out val) &&
                 Expression.IsTrue(val))
             {
                 this.TailSelect(resources, root,
                                 PathGenerator.Generate(lastNode, index, options),
                                 item, receiver, options, depth);
             }
             ++index;
         }
     }
     else if (current.ValueKind == JsonValueKind.Object)
     {
         foreach (var property in current.EnumerateObject())
         {
             IValue val;
             if (_expr.TryEvaluate(resources, root, property.Value, options, out val) &&
                 Expression.IsTrue(val))
             {
                 this.TailSelect(resources, root,
                                 PathGenerator.Generate(lastNode, property.Name, options),
                                 property.Value, receiver, options, depth);
             }
         }
     }
 }
 public override bool TryEvaluate(DynamicResources resources, IValue root,
                                  JsonLocationNode lastNode,
                                  IValue current,
                                  ProcessingFlags options,
                                  out IValue value)
 {
     if (current.ValueKind == JsonValueKind.Object)
     {
         IValue element;
         if (current.TryGetProperty(_identifier, out element))
         {
             return(this.TryEvaluateTail(resources, root,
                                         PathGenerator.Generate(lastNode, _identifier, options),
                                         element, options, out value));
         }
         else
         {
             value = JsonConstants.Null;
             return(true);
         }
     }
     else if (current.ValueKind == JsonValueKind.Array && _identifier == "length")
     {
         value = new DecimalValue(new Decimal(current.GetArrayLength()));
         return(true);
     }
     else if (current.ValueKind == JsonValueKind.String && _identifier == "length")
     {
         byte[] bytes = Encoding.UTF32.GetBytes(current.GetString().ToCharArray());
         value = new DecimalValue(new Decimal(current.GetString().Length));
         return(true);
     }
     else
     {
         value = JsonConstants.Null;
         return(true);
     }
 }
        public override void Select(DynamicResources resources,
                                    IValue root,
                                    JsonLocationNode lastNode,
                                    IValue current,
                                    INodeReceiver receiver,
                                    ProcessingFlags options,
                                    int depth)
        {
            if (depth >= resources.Options.MaxDepth)
            {
                throw new InvalidOperationException($"Maximum depth level exceeded in recursive descent selector.");
            }

            if (current.ValueKind == JsonValueKind.Array)
            {
                this.TailSelect(resources, root, lastNode, current, receiver, options, depth + 1);
                Int32 index = 0;
                foreach (var item in current.EnumerateArray())
                {
                    Select(resources, root,
                           PathGenerator.Generate(lastNode, index, options),
                           item, receiver, options, depth + 1);
                    ++index;
                }
            }
            else if (current.ValueKind == JsonValueKind.Object)
            {
                this.TailSelect(resources, root, lastNode, current, receiver, options, depth + 1);
                foreach (var prop in current.EnumerateObject())
                {
                    Select(resources, root,
                           PathGenerator.Generate(lastNode, prop.Name, options),
                           prop.Value, receiver, options, depth + 1);
                }
            }
        }
 public override bool TryEvaluate(DynamicResources resources, IValue root,
                                  JsonLocationNode lastNode,
                                  IValue current,
                                  ProcessingFlags options,
                                  out IValue value)
 {
     if (current.ValueKind == JsonValueKind.Array)
     {
         if (_index >= 0 && _index < current.GetArrayLength())
         {
             return(this.TryEvaluateTail(resources, root,
                                         PathGenerator.Generate(lastNode, _index, options),
                                         current[_index], options, out value));
         }
         else
         {
             Int32 index = current.GetArrayLength() + _index;
             if (index >= 0 && index < current.GetArrayLength())
             {
                 return(this.TryEvaluateTail(resources, root,
                                             PathGenerator.Generate(lastNode, _index, options),
                                             current[index], options, out value));
             }
             else
             {
                 value = JsonConstants.Null;
                 return(true);
             }
         }
     }
     else
     {
         value = JsonConstants.Null;
         return(true);
     }
 }