-Added ReadAsInt32 to JsonReader

-Improved performance by using an enum rather than a type check to test contract type
This commit is contained in:
JamesNK
2012-01-22 01:51:01 +00:00
parent cd424a7bc5
commit 58d51cda5c
24 changed files with 398 additions and 238 deletions
+10 -4
View File
@@ -97,7 +97,7 @@ namespace Newtonsoft.Json
}
// current Token data
private JsonToken _token;
private JsonToken _tokenType;
private object _value;
private char _quoteChar;
internal State _currentState;
@@ -146,7 +146,7 @@ namespace Newtonsoft.Json
/// </summary>
public virtual JsonToken TokenType
{
get { return _token; }
get { return _tokenType; }
}
/// <summary>
@@ -222,6 +222,12 @@ namespace Newtonsoft.Json
/// <returns>true if the next token was read successfully; false if there are no more tokens to read.</returns>
public abstract bool Read();
/// <summary>
/// Reads the next JSON token from the stream as a <see cref="Nullable{Int32}"/>.
/// </summary>
/// <returns>A <see cref="Nullable{Int32}"/>.</returns>
public abstract int? ReadAsInt32();
/// <summary>
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
/// </summary>
@@ -276,7 +282,7 @@ namespace Newtonsoft.Json
/// <param name="value">The value.</param>
protected void SetToken(JsonToken newToken, object value)
{
_token = newToken;
_tokenType = newToken;
switch (newToken)
{
@@ -447,7 +453,7 @@ namespace Newtonsoft.Json
public virtual void Close()
{
_currentState = State.Closed;
_token = JsonToken.None;
_tokenType = JsonToken.None;
_value = null;
}