-Lots and lots of JSON Schema work

-JSON Schema spec tests added
-Added Path to JToken
-Fixed JTokenWriter returning null reference
-Build script logging
-Documentation
-Updated to NUnit 2.6
This commit is contained in:
James Newton-King
2012-12-31 00:53:08 +13:00
parent 86a9b7b66b
commit e3a720504e
110 changed files with 19585 additions and 5992 deletions
+40
View File
@@ -30,6 +30,7 @@ using System.Dynamic;
using System.Linq.Expressions;
#endif
using System.IO;
using System.Text;
using Newtonsoft.Json.Utilities;
using System.Diagnostics;
using System.Globalization;
@@ -1699,5 +1700,44 @@ namespace Newtonsoft.Json.Linq
{
return CloneToken();
}
public string Path
{
get
{
IList<JToken> ancestors = Ancestors().Reverse().ToList();
ancestors.Add(this);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ancestors.Count; i++)
{
JToken current = ancestors[i];
JToken next = (i + 1 < ancestors.Count) ? ancestors[i + 1] : null;
if (next != null)
{
switch (current.Type)
{
case JTokenType.Property:
JProperty property = (JProperty) current;
if (sb.Length > 0)
sb.Append(".");
sb.Append(property.Name);
break;
case JTokenType.Array:
case JTokenType.Constructor:
int index = ((IList<JToken>)current).IndexOf(next);
sb.Append("[" + index + "]");
break;
}
}
}
return sb.ToString();
}
}
}
}