From cd0bc9591d6e03905a83c0d2764d16a0af609f2f Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 30 Nov 2013 13:13:02 +1300 Subject: [PATCH] -JsonPath++ --- .../Linq/JsonPath/AndFilter.cs | 23 -------------- Src/Newtonsoft.Json/Linq/JsonPath/OrFilter.cs | 31 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 Src/Newtonsoft.Json/Linq/JsonPath/AndFilter.cs delete mode 100644 Src/Newtonsoft.Json/Linq/JsonPath/OrFilter.cs diff --git a/Src/Newtonsoft.Json/Linq/JsonPath/AndFilter.cs b/Src/Newtonsoft.Json/Linq/JsonPath/AndFilter.cs deleted file mode 100644 index effb2cd3..00000000 --- a/Src/Newtonsoft.Json/Linq/JsonPath/AndFilter.cs +++ /dev/null @@ -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 Filters { get; set; } - - public override IEnumerable ExecuteFilter(IEnumerable current, bool errorWhenNoMatch) - { - foreach (PathFilter f in Filters) - { - current = f.ExecuteFilter(current, errorWhenNoMatch).ToList(); - } - - return current; - } - } -} \ No newline at end of file diff --git a/Src/Newtonsoft.Json/Linq/JsonPath/OrFilter.cs b/Src/Newtonsoft.Json/Linq/JsonPath/OrFilter.cs deleted file mode 100644 index 12601ce1..00000000 --- a/Src/Newtonsoft.Json/Linq/JsonPath/OrFilter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Newtonsoft.Json.Linq.JsonPath -{ - internal class OrFilter : PathFilter - { - public List Filters { get; set; } - - public override IEnumerable ExecuteFilter(IEnumerable current, bool errorWhenNoMatch) - { - List cachedCurrent = current.ToList(); - List remaining = cachedCurrent.ToList(); - List matches = new List(); - 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); - } - } -} \ No newline at end of file