public abstract void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth);
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (current.ValueKind == JsonValueKind.Array) { if (_index >= 0 && _index < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _index, options), current[_index], receiver, options, depth); } else { Int32 index = current.GetArrayLength() + _index; if (index >= 0 && index < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _index, options), current[index], 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()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, index, options), item, receiver, options, depth); ++index; } } else if (current.ValueKind == JsonValueKind.Object) { foreach (var prop in current.EnumerateObject()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, prop.Name, options), prop.Value, receiver, options, depth); } } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { JsonLocationNode?ancestor = lastNode; int index = 0; while (ancestor != null && index < _ancestorDepth) { ancestor = ancestor.Parent; ++index; } if (ancestor != null) { JsonLocation path = new JsonLocation(ancestor); IValue value; if (TryGetValue(root, path, out value)) { this.TailSelect(resources, root, path.Last, value, receiver, options, depth); } } }
public override void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { this.TailSelect(resources, root, lastNode, current, 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 start = _slice.GetStart(current.GetArrayLength()); Int32 end = _slice.GetStop(current.GetArrayLength()); Int32 step = _slice.Step; if (step > 0) { if (start < 0) { start = 0; } if (end > current.GetArrayLength()) { end = current.GetArrayLength(); } for (Int32 i = start; i < end; i += step) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, i, options), current[i], receiver, options, depth); } } else if (step < 0) { if (start >= current.GetArrayLength()) { start = current.GetArrayLength() - 1; } if (end < -1) { end = -1; } for (Int32 i = start; i > end; i += step) { if (i < current.GetArrayLength()) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, i, options), current[i], receiver, options, depth); } } } } }
protected void TailSelect(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (Tail == null) { receiver.Add(lastNode, current); } else { Tail.Select(resources, root, lastNode, current, 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.Object) { IValue value; if (current.TryGetProperty(_identifier, out value)) { this.TailSelect(resources, root, PathGenerator.Generate(lastNode, _identifier, options), value, receiver, options, depth); } } }
public void Select(DynamicResources resources, IValue root, JsonLocationNode lastNode, IValue current, INodeReceiver receiver, ProcessingFlags options, int depth) { if (resources.Options.ExecutionMode == PathExecutionMode.Sequential) { foreach (var selector in _selectors) { selector.Select(resources, root, lastNode, current, receiver, options, depth); } } else { Action <int> action = delegate(int i) { _selectors[i].Select(resources, root, lastNode, current, receiver, options, depth); }; Parallel.For(0, _selectors.Count, action); } }
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); } } }
internal SynchronizedNodeReceiver(INodeReceiver receiver) { _accumulator = receiver; }