-Formatting

-Build
This commit is contained in:
James Newton-King
2015-12-04 23:54:38 +13:00
parent c96779dc10
commit eb0cbd6a75
334 changed files with 3952 additions and 514 deletions
+36
View File
@@ -45,7 +45,9 @@ namespace Newtonsoft.Json.Linq
public IEnumerator<JToken> GetEnumerator()
{
if (_token != null)
{
yield return _token;
}
}
IEnumerator IEnumerable.GetEnumerator()
@@ -71,7 +73,9 @@ namespace Newtonsoft.Json.Linq
public void CopyTo(JToken[] array, int arrayIndex)
{
if (_token != null)
{
array[arrayIndex] = _token;
}
}
public bool Remove(JToken item)
@@ -102,13 +106,17 @@ namespace Newtonsoft.Json.Linq
public void Insert(int index, JToken item)
{
if (index == 0)
{
_token = item;
}
}
public void RemoveAt(int index)
{
if (index == 0)
{
_token = null;
}
}
public JToken this[int index]
@@ -117,7 +125,9 @@ namespace Newtonsoft.Json.Linq
set
{
if (index == 0)
{
_token = value;
}
}
}
}
@@ -183,7 +193,9 @@ namespace Newtonsoft.Json.Linq
internal override JToken GetItem(int index)
{
if (index != 0)
{
throw new ArgumentOutOfRangeException();
}
return Value;
}
@@ -191,18 +203,26 @@ namespace Newtonsoft.Json.Linq
internal override void SetItem(int index, JToken item)
{
if (index != 0)
{
throw new ArgumentOutOfRangeException();
}
if (IsTokenUnchanged(Value, item))
{
return;
}
if (Parent != null)
{
((JObject)Parent).InternalPropertyChanging(this);
}
base.SetItem(0, item);
if (Parent != null)
{
((JObject)Parent).InternalPropertyChanged(this);
}
}
internal override bool RemoveItem(JToken item)
@@ -219,10 +239,14 @@ namespace Newtonsoft.Json.Linq
{
// don't add comments to JProperty
if (item != null && item.Type == JTokenType.Comment)
{
return;
}
if (Value != null)
{
throw new JsonException("{0} cannot have multiple values.".FormatWith(CultureInfo.InvariantCulture, typeof(JProperty)));
}
base.InsertItem(0, item, false);
}
@@ -236,10 +260,14 @@ namespace Newtonsoft.Json.Linq
{
JProperty p = content as JProperty;
if (p == null)
{
return;
}
if (p.Value != null && p.Value.Type != JTokenType.Null)
{
Value = p.Value;
}
}
internal override void ClearItems()
@@ -313,9 +341,13 @@ namespace Newtonsoft.Json.Linq
JToken value = Value;
if (value != null)
{
value.WriteTo(writer, converters);
}
else
{
writer.WriteNull();
}
}
internal override int GetDeepHashCode()
@@ -345,7 +377,9 @@ namespace Newtonsoft.Json.Linq
if (reader.TokenType == JsonToken.None)
{
if (!reader.Read())
{
throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
}
}
while (reader.TokenType == JsonToken.Comment)
@@ -354,7 +388,9 @@ namespace Newtonsoft.Json.Linq
}
if (reader.TokenType != JsonToken.PropertyName)
{
throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
}
JProperty p = new JProperty((string)reader.Value);
p.SetLineInfo(reader as IJsonLineInfo, settings);