-Added missing XML comments to new members/classes

-Fixed culture warnings
This commit is contained in:
JamesNK
2008-08-14 07:50:48 +00:00
parent f9772626b8
commit ee281662c4
6 changed files with 119 additions and 8 deletions
@@ -7,16 +7,27 @@ using System.Globalization;
namespace Newtonsoft.Json namespace Newtonsoft.Json
{ {
/// <summary>
/// Instructs the <see cref="JsonSerializer"/> to use the specified <see cref="JsonConverter"/> when serializing the member or class.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false)]
public class JsonConverterAttribute : Attribute public class JsonConverterAttribute : Attribute
{ {
private readonly Type _converterType; private readonly Type _converterType;
/// <summary>
/// Gets the type of the converter.
/// </summary>
/// <value>The type of the converter.</value>
public Type ConverterType public Type ConverterType
{ {
get { return _converterType; } get { return _converterType; }
} }
/// <summary>
/// Initializes a new instance of the <see cref="JsonConverterAttribute"/> class.
/// </summary>
/// <param name="converterType">Type of the converter.</param>
public JsonConverterAttribute(Type converterType) public JsonConverterAttribute(Type converterType)
{ {
if (converterType == null) if (converterType == null)
+56 -1
View File
@@ -189,6 +189,10 @@ namespace Newtonsoft.Json.Linq
} }
} }
/// <summary>
/// Gets or sets the <see cref="Newtonsoft.Json.Linq.JToken"/> at the specified index.
/// </summary>
/// <value></value>
public JToken this[int index] public JToken this[int index]
{ {
get get
@@ -204,6 +208,13 @@ namespace Newtonsoft.Json.Linq
#region IList<JToken> Members #region IList<JToken> Members
/// <summary>
/// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1"/>.
/// </summary>
/// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
/// <returns>
/// The index of <paramref name="item"/> if found in the list; otherwise, -1.
/// </returns>
public int IndexOf(JToken item) public int IndexOf(JToken item)
{ {
int index = 0; int index = 0;
@@ -218,6 +229,14 @@ namespace Newtonsoft.Json.Linq
return -1; return -1;
} }
/// <summary>
/// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> at the specified index.
/// </summary>
/// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
/// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index"/> is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"/>.</exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.</exception>
public void Insert(int index, JToken item) public void Insert(int index, JToken item)
{ {
if (index == 0) if (index == 0)
@@ -231,6 +250,13 @@ namespace Newtonsoft.Json.Linq
} }
} }
/// <summary>
/// Removes the <see cref="T:System.Collections.Generic.IList`1"/> item at the specified index.
/// </summary>
/// <param name="index">The zero-based index of the item to remove.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index"/> is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"/>.</exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.</exception>
public void RemoveAt(int index) public void RemoveAt(int index)
{ {
if (index < 0) if (index < 0)
@@ -255,16 +281,32 @@ namespace Newtonsoft.Json.Linq
#region ICollection<JToken> Members #region ICollection<JToken> Members
/// <summary>
/// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </summary>
/// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception>
public void Add(JToken item) public void Add(JToken item)
{ {
Add((object)item); Add((object)item);
} }
/// <summary>
/// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </summary>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only. </exception>
public void Clear() public void Clear()
{ {
RemoveAll(); RemoveAll();
} }
/// <summary>
/// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
/// </summary>
/// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
/// <returns>
/// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false.
/// </returns>
public bool Contains(JToken item) public bool Contains(JToken item)
{ {
return Children().Contains(item); return Children().Contains(item);
@@ -289,6 +331,11 @@ namespace Newtonsoft.Json.Linq
} }
} }
/// <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 public int Count
{ {
get { return Children().Count(); } get { return Children().Count(); }
@@ -299,7 +346,15 @@ namespace Newtonsoft.Json.Linq
get { return false; } get { return false; }
} }
public bool Remove(JToken item) /// <summary>
/// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </summary>
/// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
/// <returns>
/// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </returns>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception>
public new bool Remove(JToken item)
{ {
if (!((ICollection<JToken>)this).Contains(item)) if (!((ICollection<JToken>)this).Contains(item))
return false; return false;
+25
View File
@@ -153,6 +153,10 @@ namespace Newtonsoft.Json.Linq
} }
} }
/// <summary>
/// Gets or sets the <see cref="Newtonsoft.Json.Linq.JToken"/> with the specified property name.
/// </summary>
/// <value></value>
public JToken this[string propertyName] public JToken this[string propertyName]
{ {
get get
@@ -256,6 +260,11 @@ namespace Newtonsoft.Json.Linq
} }
#region IDictionary<string,JToken> Members #region IDictionary<string,JToken> Members
/// <summary>
/// Adds the specified property name.
/// </summary>
/// <param name="propertyName">Name of the property.</param>
/// <param name="value">The value.</param>
public void Add(string propertyName, JToken value) public void Add(string propertyName, JToken value)
{ {
Add(new JProperty(propertyName, value)); Add(new JProperty(propertyName, value));
@@ -271,6 +280,11 @@ namespace Newtonsoft.Json.Linq
get { throw new NotImplementedException(); } get { throw new NotImplementedException(); }
} }
/// <summary>
/// Removes the specified property name.
/// </summary>
/// <param name="propertyName">Name of the property.</param>
/// <returns></returns>
public bool Remove(string propertyName) public bool Remove(string propertyName)
{ {
JProperty property = Property(propertyName); JProperty property = Property(propertyName);
@@ -281,6 +295,12 @@ namespace Newtonsoft.Json.Linq
return true; return true;
} }
/// <summary>
/// Tries the get value.
/// </summary>
/// <param name="propertyName">Name of the property.</param>
/// <param name="value">The value.</param>
/// <returns></returns>
public bool TryGetValue(string propertyName, out JToken value) public bool TryGetValue(string propertyName, out JToken value)
{ {
JProperty property = Property(propertyName); JProperty property = Property(propertyName);
@@ -341,6 +361,11 @@ namespace Newtonsoft.Json.Linq
} }
} }
/// <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 public int Count
{ {
get { return Children().Count(); } get { return Children().Count(); }
+4
View File
@@ -44,6 +44,10 @@ namespace Newtonsoft.Json.Linq
internal JToken _next; internal JToken _next;
private static JTokenEqualityComparer _equalityComparer; private static JTokenEqualityComparer _equalityComparer;
/// <summary>
/// Gets a comparer that can compare two tokens for value equality.
/// </summary>
/// <value>A <see cref="JTokenEqualityComparer"/> that can compare two nodes for value equality.</value>
public static JTokenEqualityComparer EqualityComparer public static JTokenEqualityComparer EqualityComparer
{ {
get get
@@ -5,13 +5,30 @@ using System.Text;
namespace Newtonsoft.Json.Linq namespace Newtonsoft.Json.Linq
{ {
/// <summary>
/// Compares tokens to determine whether they are equal.
/// </summary>
public class JTokenEqualityComparer : IEqualityComparer<JToken> public class JTokenEqualityComparer : IEqualityComparer<JToken>
{ {
/// <summary>
/// Determines whether the specified objects are equal.
/// </summary>
/// <param name="x">The first object of type <paramref name="T"/> to compare.</param>
/// <param name="y">The second object of type <paramref name="T"/> to compare.</param>
/// <returns>
/// true if the specified objects are equal; otherwise, false.
/// </returns>
public bool Equals(JToken x, JToken y) public bool Equals(JToken x, JToken y)
{ {
return JToken.DeepEquals(x, y); return JToken.DeepEquals(x, y);
} }
/// <summary>
/// Returns a hash code for the specified object.
/// </summary>
/// <param name="obj">The <see cref="T:System.Object"/> for which a hash code is to be returned.</param>
/// <returns>A hash code for the specified object.</returns>
/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj"/> is a reference type and <paramref name="obj"/> is null.</exception>
public int GetHashCode(JToken obj) public int GetHashCode(JToken obj)
{ {
if (obj == null) if (obj == null)
@@ -79,7 +79,7 @@ namespace Newtonsoft.Json.Utilities
return initialValue; return initialValue;
if (targetType.IsInterface || targetType.IsGenericTypeDefinition || targetType.IsAbstract) if (targetType.IsInterface || targetType.IsGenericTypeDefinition || targetType.IsAbstract)
throw new ArgumentException(string.Format("Target type {0} is not a value type or a non-abstract class.", targetType), "targetType"); throw new ArgumentException("Target type {0} is not a value type or a non-abstract class.".FormatWith(CultureInfo.InvariantCulture, targetType), "targetType");
// use Convert.ChangeType if both types are IConvertible // use Convert.ChangeType if both types are IConvertible
@@ -131,7 +131,7 @@ namespace Newtonsoft.Json.Utilities
if (ReflectionUtils.IsNullable(targetType)) if (ReflectionUtils.IsNullable(targetType))
return EnsureTypeAssignable(null, initialType, targetType); return EnsureTypeAssignable(null, initialType, targetType);
else else
throw new Exception(string.Format("Can not convert null {0} into non-nullable {1}.", initialType, targetType)); throw new Exception("Can not convert null {0} into non-nullable {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
} }
#if !SILVERLIGHT #if !SILVERLIGHT
else if (initialValue is INullable) else if (initialValue is INullable)
@@ -140,7 +140,7 @@ namespace Newtonsoft.Json.Utilities
} }
#endif #endif
throw new Exception(string.Format("Can not convert from {0} to {1}.", initialType, targetType)); throw new Exception("Can not convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType));
} }
#endregion #endregion
@@ -287,7 +287,7 @@ namespace Newtonsoft.Json.Utilities
/// </summary> /// </summary>
/// <param name="initialValue">The value to convert.</param> /// <param name="initialValue">The value to convert.</param>
/// <param name="culture">The culture to use when converting.</param> /// <param name="culture">The culture to use when converting.</param>
/// <param name="targetType">The type to convert the value to.</typeparam> /// <param name="targetType">The type to convert the value to.</param>
/// <param name="convertedValue">The converted value if the conversion was successful or the default value of <c>T</c> if it failed.</param> /// <param name="convertedValue">The converted value if the conversion was successful or the default value of <c>T</c> if it failed.</param>
/// <returns> /// <returns>
/// <c>true</c> if <c>initialValue</c> was converted successfully or is assignable; otherwise, <c>false</c>. /// <c>true</c> if <c>initialValue</c> was converted successfully or is assignable; otherwise, <c>false</c>.
@@ -307,8 +307,7 @@ namespace Newtonsoft.Json.Utilities
else if (value == null && ReflectionUtils.IsNullable(targetType)) else if (value == null && ReflectionUtils.IsNullable(targetType))
return null; return null;
else else
throw new Exception(string.Format("Could not cast or convert from {0} to {1}.", throw new Exception("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, (initialType != null) ? initialType.ToString() : "{null}", targetType));
(initialType != null) ? initialType.ToString() : "{null}", targetType));
} }
#if !SILVERLIGHT #if !SILVERLIGHT
@@ -327,7 +326,7 @@ namespace Newtonsoft.Json.Utilities
else if (nullableValue is SqlDateTime) else if (nullableValue is SqlDateTime)
return ToValue((SqlDateTime)nullableValue); return ToValue((SqlDateTime)nullableValue);
throw new Exception(string.Format("Unsupported INullable type: {0}", nullableValue.GetType())); throw new Exception("Unsupported INullable type: {0}".FormatWith(CultureInfo.InvariantCulture, nullableValue.GetType()));
} }
#endif #endif