Skip to content

Commit

Permalink
-Added some XML comments
Browse files Browse the repository at this point in the history
-Made some utility methods internal
  • Loading branch information
JamesNK committed Apr 8, 2008
1 parent ffe2d91 commit 11ef223
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 23 deletions.
23 changes: 23 additions & 0 deletions Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,28 @@ public void FloatingPointNonFiniteNumbers()
Assert.AreEqual(jsonReader.TokenType, JsonToken.EndArray);
}
}

[Test]
public void LongStringTest()
{
int length = 20000;
string json = @"[""" + new string(' ', length) + @"""]";

JsonTextReader reader = new JsonTextReader(new StringReader(json));

reader.Read();
Assert.AreEqual(JsonToken.StartArray, reader.TokenType);

reader.Read();
Assert.AreEqual(JsonToken.String, reader.TokenType);
Assert.AreEqual(typeof(string), reader.ValueType);
Assert.AreEqual(20000, reader.Value.ToString().Length);

reader.Read();
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);

reader.Read();
Assert.AreEqual(JsonToken.EndArray, reader.TokenType);
}
}
}
3 changes: 3 additions & 0 deletions Src/Newtonsoft.Json/JsonReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ private JsonTokenType GetTypeForCloseToken(JsonToken token)
}
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
void IDisposable.Dispose()
{
Dispose(true);
Expand Down
9 changes: 9 additions & 0 deletions Src/Newtonsoft.Json/Linq/JConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public string Name
set { _name = value; }
}

/// <summary>
/// Gets the node type for this <see cref="JToken"/>.
/// </summary>
/// <value>The type.</value>
public override JsonTokenType Type
{
get { return JsonTokenType.Constructor; }
Expand Down Expand Up @@ -95,6 +99,11 @@ internal override void ValidateObject(JToken o, JToken previous)
}
}

/// <summary>
/// Writes this token to a <see cref="JsonWriter"/>.
/// </summary>
/// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param>
/// <param name="converters">A collection of <see cref="JsonConverter"/> which will be used when writing the token.</param>
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
{
writer.WriteStartConstructor(_name);
Expand Down
23 changes: 23 additions & 0 deletions Src/Newtonsoft.Json/Linq/JContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ protected JContainer()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="JContainer"/> class from another <see cref="JContainer"/> object.
/// </summary>
/// <param name="other">A <see cref="JContainer"/> object to copy from.</param>
protected JContainer(JContainer other)
{
ValidationUtils.ArgumentNotNull(other, "c");
Expand All @@ -64,6 +68,12 @@ protected JContainer(JContainer other)
}
}

/// <summary>
/// Gets a value indicating whether this token has childen tokens.
/// </summary>
/// <value>
/// <c>true</c> if this token has child values; otherwise, <c>false</c>.
/// </value>
public override bool HasValues
{
get { return (_content != null); }
Expand Down Expand Up @@ -112,6 +122,12 @@ public override JToken Last
get { return _content; }
}

/// <summary>
/// Returns a collection of the child tokens of this token, in document order.
/// </summary>
/// <returns>
/// An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> containing the child tokens of this <see cref="JToken"/>, in document order.
/// </returns>
public override JEnumerable<JToken> Children()
{
return new JEnumerable<JToken>(ChildrenInternal());
Expand All @@ -132,6 +148,13 @@ private IEnumerable<JToken> ChildrenInternal()
&& ((current = current.Next) != null));
}

/// <summary>
/// Returns a collection of the child values of this token, in document order.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>
/// A <see cref="IEnumerable{T}"/> containing the child values of this <see cref="JToken"/>, in document order.
/// </returns>
public override IEnumerable<T> Values<T>()
{
return Children().Convert<JToken, T>();
Expand Down
10 changes: 10 additions & 0 deletions Src/Newtonsoft.Json/Linq/JObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@

namespace Newtonsoft.Json.Linq
{
/// <summary>
/// Represents a JSON object.
/// </summary>
public class JObject : JContainer
{
/// <summary>
/// Initializes a new instance of the <see cref="JObject"/> class.
/// </summary>
public JObject()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="JObject"/> class from another <see cref="JObject"/> object.
/// </summary>
/// <param name="other">A <see cref="JObject"/> object to copy from.</param>
public JObject(JObject other)
: base(other)
{
Expand Down
38 changes: 34 additions & 4 deletions Src/Newtonsoft.Json/Linq/JProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,38 @@

namespace Newtonsoft.Json.Linq
{
/// <summary>
/// Represents a JSON property.
/// </summary>
public class JProperty : JContainer
{
private readonly string _name;

/// <summary>
/// Gets the property name.
/// </summary>
/// <value>The property name.</value>
public string Name
{
[DebuggerStepThrough]
get { return _name; }
}

/// <summary>
/// Gets or sets the property value.
/// </summary>
/// <value>The property value.</value>
public JToken Value
{
[DebuggerStepThrough]
get { return Last; }
set
{
ReplaceAll(value);
}
set { ReplaceAll(value); }
}

/// <summary>
/// Initializes a new instance of the <see cref="JProperty"/> class from another <see cref="JProperty"/> object.
/// </summary>
/// <param name="other">A <see cref="JProperty"/> object to copy from.</param>
public JProperty(JProperty other)
: base(other)
{
Expand All @@ -70,19 +82,32 @@ internal override JToken CloneNode()
return new JProperty(this);
}

/// <summary>
/// Gets the node type for this <see cref="JToken"/>.
/// </summary>
/// <value>The type.</value>
public override JsonTokenType Type
{
[DebuggerStepThrough]
get { return JsonTokenType.Property; }
}

/// <summary>
/// Initializes a new instance of the <see cref="JProperty"/> class.
/// </summary>
/// <param name="name">The property name.</param>
public JProperty(string name)
{
ValidationUtils.ArgumentNotNull(name, "name");

_name = name;
}

/// <summary>
/// Initializes a new instance of the <see cref="JProperty"/> class.
/// </summary>
/// <param name="name">The property name.</param>
/// <param name="value">The property value.</param>
public JProperty(string name, object value)
{
ValidationUtils.ArgumentNotNullOrEmpty(name, "name");
Expand All @@ -99,6 +124,11 @@ internal override void ValidateObject(JToken o, JToken previous)
throw new ArgumentException("An item of type {0} cannot be added to content.".FormatWith(CultureInfo.InvariantCulture, o.Type));
}

/// <summary>
/// Writes this token to a <see cref="JsonWriter"/>.
/// </summary>
/// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param>
/// <param name="converters">A collection of <see cref="JsonConverter"/> which will be used when writing the token.</param>
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
{
writer.WritePropertyName(_name);
Expand Down
Loading

0 comments on commit 11ef223

Please sign in to comment.