Merge branch 'master' of github.com:JamesNK/Newtonsoft.Json
Conflicts: Src/Newtonsoft.Json/JsonWriter.cs
This commit is contained in:
@@ -54,7 +54,6 @@ namespace Newtonsoft.Json
|
||||
Array,
|
||||
ConstructorStart,
|
||||
Constructor,
|
||||
Bytes,
|
||||
Closed,
|
||||
Error
|
||||
}
|
||||
@@ -69,7 +68,7 @@ namespace Newtonsoft.Json
|
||||
/* StartObject */new[]{ State.ObjectStart, State.ObjectStart, State.Error, State.Error, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.Error, State.Error },
|
||||
/* StartArray */new[]{ State.ArrayStart, State.ArrayStart, State.Error, State.Error, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.Error, State.Error },
|
||||
/* StartConstructor */new[]{ State.ConstructorStart, State.ConstructorStart, State.Error, State.Error, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.Error, State.Error },
|
||||
/* StartProperty */new[]{ State.Property, State.Error, State.Property, State.Property, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error },
|
||||
/* Property */new[]{ State.Property, State.Error, State.Property, State.Property, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error },
|
||||
/* Comment */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
||||
/* Raw */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
||||
/* Value (this will be copied) */new[]{ State.Start, State.Object, State.Error, State.Error, State.Array, State.Array, State.Constructor, State.Constructor, State.Error, State.Error }
|
||||
@@ -142,7 +141,7 @@ namespace Newtonsoft.Json
|
||||
return depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state of the writer.
|
||||
/// </summary>
|
||||
@@ -304,10 +303,15 @@ namespace Newtonsoft.Json
|
||||
/// Writes the beginning of a Json object.
|
||||
/// </summary>
|
||||
public virtual void WriteStartObject()
|
||||
{
|
||||
InternalWriteStart(JsonToken.StartObject, JsonContainerType.Object);
|
||||
}
|
||||
|
||||
internal void InternalWriteStart(JsonToken token, JsonContainerType container)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.StartObject);
|
||||
Push(JsonContainerType.Object);
|
||||
AutoComplete(token);
|
||||
Push(container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -315,7 +319,7 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
public virtual void WriteEndObject()
|
||||
{
|
||||
AutoCompleteClose(JsonContainerType.Object);
|
||||
InternalWriteEnd(JsonContainerType.Object);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -323,9 +327,7 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
public virtual void WriteStartArray()
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.StartArray);
|
||||
Push(JsonContainerType.Array);
|
||||
InternalWriteStart(JsonToken.StartArray, JsonContainerType.Array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -333,7 +335,7 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
public virtual void WriteEndArray()
|
||||
{
|
||||
AutoCompleteClose(JsonContainerType.Array);
|
||||
InternalWriteEnd(JsonContainerType.Array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -342,9 +344,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="name">The name of the constructor.</param>
|
||||
public virtual void WriteStartConstructor(string name)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.StartConstructor);
|
||||
Push(JsonContainerType.Constructor);
|
||||
InternalWriteStart(JsonToken.StartConstructor, JsonContainerType.Constructor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -352,7 +352,12 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
public virtual void WriteEndConstructor()
|
||||
{
|
||||
AutoCompleteClose(JsonContainerType.Constructor);
|
||||
InternalWriteEnd(JsonContainerType.Constructor);
|
||||
}
|
||||
|
||||
internal void InternalWriteEnd(JsonContainerType container)
|
||||
{
|
||||
AutoCompleteClose(container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -360,6 +365,11 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the property.</param>
|
||||
public virtual void WritePropertyName(string name)
|
||||
{
|
||||
InternalWritePropertyName(name);
|
||||
}
|
||||
|
||||
internal void InternalWritePropertyName(string name)
|
||||
{
|
||||
_currentPosition.PropertyName = name;
|
||||
AutoComplete(JsonToken.PropertyName);
|
||||
@@ -672,22 +682,16 @@ namespace Newtonsoft.Json
|
||||
{
|
||||
WriteValueDelimiter();
|
||||
}
|
||||
else if (_currentState == State.Property)
|
||||
{
|
||||
if (_formatting == Formatting.Indented)
|
||||
WriteIndentSpace();
|
||||
}
|
||||
|
||||
if (_formatting == Formatting.Indented)
|
||||
{
|
||||
WriteState writeState = WriteState;
|
||||
if (_currentState == State.Property)
|
||||
WriteIndentSpace();
|
||||
|
||||
// don't indent a property when it is the first token to be written (i.e. at the start)
|
||||
if ((tokenBeingWritten == JsonToken.PropertyName && writeState != WriteState.Start) ||
|
||||
writeState == WriteState.Array || writeState == WriteState.Constructor)
|
||||
{
|
||||
if ((_currentState == State.Array || _currentState == State.ArrayStart || _currentState == State.Constructor || _currentState == State.ConstructorStart)
|
||||
|| (tokenBeingWritten == JsonToken.PropertyName && _currentState != State.Start))
|
||||
WriteIndent();
|
||||
}
|
||||
}
|
||||
|
||||
_currentState = newState;
|
||||
@@ -698,6 +702,11 @@ namespace Newtonsoft.Json
|
||||
/// Writes a null value.
|
||||
/// </summary>
|
||||
public virtual void WriteNull()
|
||||
{
|
||||
InternalWriteNull();
|
||||
}
|
||||
|
||||
internal void InternalWriteNull()
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Null);
|
||||
@@ -707,6 +716,11 @@ namespace Newtonsoft.Json
|
||||
/// Writes an undefined value.
|
||||
/// </summary>
|
||||
public virtual void WriteUndefined()
|
||||
{
|
||||
InternalWriteUndefined();
|
||||
}
|
||||
|
||||
internal void InternalWriteUndefined()
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Undefined);
|
||||
@@ -717,6 +731,11 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <param name="json">The raw JSON to write.</param>
|
||||
public virtual void WriteRaw(string json)
|
||||
{
|
||||
InternalWriteRaw();
|
||||
}
|
||||
|
||||
internal void InternalWriteRaw()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -737,9 +756,14 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="String"/> value to write.</param>
|
||||
public virtual void WriteValue(string value)
|
||||
{
|
||||
InternalWriteValue(JsonToken.String);
|
||||
}
|
||||
|
||||
internal void InternalWriteValue(JsonToken token)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.String);
|
||||
AutoComplete(token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -748,8 +772,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Int32"/> value to write.</param>
|
||||
public virtual void WriteValue(int value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -759,8 +782,7 @@ namespace Newtonsoft.Json
|
||||
[CLSCompliant(false)]
|
||||
public virtual void WriteValue(uint value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -769,8 +791,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Int64"/> value to write.</param>
|
||||
public virtual void WriteValue(long value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -780,8 +801,7 @@ namespace Newtonsoft.Json
|
||||
[CLSCompliant(false)]
|
||||
public virtual void WriteValue(ulong value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -790,8 +810,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Single"/> value to write.</param>
|
||||
public virtual void WriteValue(float value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Float);
|
||||
InternalWriteValue(JsonToken.Float);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -800,8 +819,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Double"/> value to write.</param>
|
||||
public virtual void WriteValue(double value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Float);
|
||||
InternalWriteValue(JsonToken.Float);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -810,8 +828,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Boolean"/> value to write.</param>
|
||||
public virtual void WriteValue(bool value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Boolean);
|
||||
InternalWriteValue(JsonToken.Boolean);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -820,8 +837,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Int16"/> value to write.</param>
|
||||
public virtual void WriteValue(short value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -831,8 +847,7 @@ namespace Newtonsoft.Json
|
||||
[CLSCompliant(false)]
|
||||
public virtual void WriteValue(ushort value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -841,8 +856,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Char"/> value to write.</param>
|
||||
public virtual void WriteValue(char value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.String);
|
||||
InternalWriteValue(JsonToken.String);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -851,8 +865,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Byte"/> value to write.</param>
|
||||
public virtual void WriteValue(byte value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -862,8 +875,7 @@ namespace Newtonsoft.Json
|
||||
[CLSCompliant(false)]
|
||||
public virtual void WriteValue(sbyte value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Integer);
|
||||
InternalWriteValue(JsonToken.Integer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -872,8 +884,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Decimal"/> value to write.</param>
|
||||
public virtual void WriteValue(decimal value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Float);
|
||||
InternalWriteValue(JsonToken.Float);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -882,8 +893,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
||||
public virtual void WriteValue(DateTime value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Date);
|
||||
InternalWriteValue(JsonToken.Date);
|
||||
}
|
||||
|
||||
#if !PocketPC && !NET20
|
||||
@@ -893,8 +903,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="DateTimeOffset"/> value to write.</param>
|
||||
public virtual void WriteValue(DateTimeOffset value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Date);
|
||||
InternalWriteValue(JsonToken.Date);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -904,8 +913,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="Guid"/> value to write.</param>
|
||||
public virtual void WriteValue(Guid value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.String);
|
||||
InternalWriteValue(JsonToken.String);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -914,8 +922,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="value">The <see cref="TimeSpan"/> value to write.</param>
|
||||
public virtual void WriteValue(TimeSpan value)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.String);
|
||||
InternalWriteValue(JsonToken.String);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1135,14 +1142,9 @@ namespace Newtonsoft.Json
|
||||
public virtual void WriteValue(byte[] value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
WriteNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.Bytes);
|
||||
}
|
||||
InternalWriteValue(JsonToken.Bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1152,14 +1154,9 @@ namespace Newtonsoft.Json
|
||||
public virtual void WriteValue(Uri value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
WriteNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
AutoComplete(JsonToken.String);
|
||||
}
|
||||
InternalWriteValue(JsonToken.String);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1270,7 +1267,11 @@ namespace Newtonsoft.Json
|
||||
/// <param name="text">Text to place inside the comment.</param>
|
||||
public virtual void WriteComment(string text)
|
||||
{
|
||||
UpdateScopeWithFinishedValue();
|
||||
InternalWriteComment();
|
||||
}
|
||||
|
||||
internal void InternalWriteComment()
|
||||
{
|
||||
AutoComplete(JsonToken.Comment);
|
||||
}
|
||||
|
||||
@@ -1279,6 +1280,11 @@ namespace Newtonsoft.Json
|
||||
/// </summary>
|
||||
/// <param name="ws">The string of white space characters.</param>
|
||||
public virtual void WriteWhitespace(string ws)
|
||||
{
|
||||
InternalWriteWhitespace(ws);
|
||||
}
|
||||
|
||||
internal void InternalWriteWhitespace(string ws)
|
||||
{
|
||||
if (ws != null)
|
||||
{
|
||||
@@ -1287,7 +1293,6 @@ namespace Newtonsoft.Json
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
Reference in New Issue
Block a user