-Added Count to JContainer
-Minor fixes and improvements
This commit is contained in:
@@ -170,7 +170,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
{
|
{
|
||||||
writer.WriteStartArray();
|
writer.WriteStartArray();
|
||||||
|
|
||||||
foreach (JToken token in Children())
|
foreach (JToken token in ChildrenTokens)
|
||||||
{
|
{
|
||||||
token.WriteTo(writer, converters);
|
token.WriteTo(writer, converters);
|
||||||
}
|
}
|
||||||
@@ -293,16 +293,6 @@ namespace Newtonsoft.Json.Linq
|
|||||||
CopyItemsTo(array, arrayIndex);
|
CopyItemsTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</returns>
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get { return CountItems(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICollection<JToken>.IsReadOnly
|
bool ICollection<JToken>.IsReadOnly
|
||||||
{
|
{
|
||||||
get { return false; }
|
get { return false; }
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
throw new ArgumentOutOfRangeException("arrayIndex", "arrayIndex is less than 0.");
|
throw new ArgumentOutOfRangeException("arrayIndex", "arrayIndex is less than 0.");
|
||||||
if (arrayIndex >= array.Length)
|
if (arrayIndex >= array.Length)
|
||||||
throw new ArgumentException("arrayIndex is equal to or greater than the length of array.");
|
throw new ArgumentException("arrayIndex is equal to or greater than the length of array.");
|
||||||
if (CountItems() > array.Length - arrayIndex)
|
if (Count > array.Length - arrayIndex)
|
||||||
throw new ArgumentException("The number of elements in the source JObject is greater than the available space from arrayIndex to the end of the destination array.");
|
throw new ArgumentException("The number of elements in the source JObject is greater than the available space from arrayIndex to the end of the destination array.");
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -490,11 +490,6 @@ namespace Newtonsoft.Json.Linq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual int CountItems()
|
|
||||||
{
|
|
||||||
return ChildrenTokens.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool IsTokenUnchanged(JToken currentValue, JToken newValue)
|
internal static bool IsTokenUnchanged(JToken currentValue, JToken newValue)
|
||||||
{
|
{
|
||||||
JValue v1 = currentValue as JValue;
|
JValue v1 = currentValue as JValue;
|
||||||
@@ -784,11 +779,6 @@ namespace Newtonsoft.Json.Linq
|
|||||||
CopyItemsTo(array, arrayIndex);
|
CopyItemsTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICollection<JToken>.Count
|
|
||||||
{
|
|
||||||
get { return CountItems(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICollection<JToken>.IsReadOnly
|
bool ICollection<JToken>.IsReadOnly
|
||||||
{
|
{
|
||||||
get { return false; }
|
get { return false; }
|
||||||
@@ -817,7 +807,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
int IList.Add(object value)
|
int IList.Add(object value)
|
||||||
{
|
{
|
||||||
Add(EnsureValue(value));
|
Add(EnsureValue(value));
|
||||||
return CountItems() - 1;
|
return Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IList.Clear()
|
void IList.Clear()
|
||||||
@@ -875,9 +865,9 @@ namespace Newtonsoft.Json.Linq
|
|||||||
CopyItemsTo(array, index);
|
CopyItemsTo(array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICollection.Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return CountItems(); }
|
get { return ChildrenTokens.Count; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection.IsSynchronized
|
bool ICollection.IsSynchronized
|
||||||
|
|||||||
@@ -386,6 +386,9 @@ namespace Newtonsoft.Json.Linq
|
|||||||
|
|
||||||
bool IDictionary<string, JToken>.ContainsKey(string key)
|
bool IDictionary<string, JToken>.ContainsKey(string key)
|
||||||
{
|
{
|
||||||
|
if (_properties.Dictionary == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
return _properties.Dictionary.ContainsKey(key);
|
return _properties.Dictionary.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +485,7 @@ namespace Newtonsoft.Json.Linq
|
|||||||
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</returns>
|
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</returns>
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return Children().Count(); }
|
get { return ChildrenTokens.Count; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string,JToken>>.IsReadOnly
|
bool ICollection<KeyValuePair<string,JToken>>.IsReadOnly
|
||||||
|
|||||||
Reference in New Issue
Block a user