-JsonPath++
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Linq.JsonPath
|
|
||||||
{
|
|
||||||
internal class AndFilter : PathFilter
|
|
||||||
{
|
|
||||||
public List<PathFilter> Filters { get; set; }
|
|
||||||
|
|
||||||
public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, bool errorWhenNoMatch)
|
|
||||||
{
|
|
||||||
foreach (PathFilter f in Filters)
|
|
||||||
{
|
|
||||||
current = f.ExecuteFilter(current, errorWhenNoMatch).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Linq.JsonPath
|
|
||||||
{
|
|
||||||
internal class OrFilter : PathFilter
|
|
||||||
{
|
|
||||||
public List<PathFilter> Filters { get; set; }
|
|
||||||
|
|
||||||
public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, bool errorWhenNoMatch)
|
|
||||||
{
|
|
||||||
List<JToken> cachedCurrent = current.ToList();
|
|
||||||
List<JToken> remaining = cachedCurrent.ToList();
|
|
||||||
List<JToken> matches = new List<JToken>();
|
|
||||||
int previousResultCount = 0;
|
|
||||||
|
|
||||||
foreach (PathFilter f in Filters)
|
|
||||||
{
|
|
||||||
matches.AddRange(f.ExecuteFilter(remaining, errorWhenNoMatch));
|
|
||||||
|
|
||||||
for (int i = previousResultCount; i < matches.Count; i++)
|
|
||||||
{
|
|
||||||
remaining.Remove(matches[i]);
|
|
||||||
}
|
|
||||||
previousResultCount = matches.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cachedCurrent.Where(matches.Contains);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user