-XML documentation
-Fixed culture warnings
This commit is contained in:
@@ -34,19 +34,9 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Bson
|
namespace Newtonsoft.Json.Bson
|
||||||
{
|
{
|
||||||
internal enum BsonReaderState
|
/// <summary>
|
||||||
{
|
/// Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
|
||||||
Normal,
|
/// </summary>
|
||||||
ReferenceStart,
|
|
||||||
ReferenceRef,
|
|
||||||
ReferenceId,
|
|
||||||
CodeWScopeStart,
|
|
||||||
CodeWScopeCode,
|
|
||||||
CodeWScopeScope,
|
|
||||||
CodeWScopeScopeObject,
|
|
||||||
CodeWScopeScopeEnd
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BsonReader : JsonReader
|
public class BsonReader : JsonReader
|
||||||
{
|
{
|
||||||
private readonly BinaryReader _reader;
|
private readonly BinaryReader _reader;
|
||||||
@@ -56,6 +46,19 @@ namespace Newtonsoft.Json.Bson
|
|||||||
private BsonType _currentElementType;
|
private BsonType _currentElementType;
|
||||||
private BsonReaderState _bsonReaderState;
|
private BsonReaderState _bsonReaderState;
|
||||||
|
|
||||||
|
private enum BsonReaderState
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
ReferenceStart,
|
||||||
|
ReferenceRef,
|
||||||
|
ReferenceId,
|
||||||
|
CodeWScopeStart,
|
||||||
|
CodeWScopeCode,
|
||||||
|
CodeWScopeScope,
|
||||||
|
CodeWScopeScopeObject,
|
||||||
|
CodeWScopeScopeEnd
|
||||||
|
}
|
||||||
|
|
||||||
private class ContainerContext
|
private class ContainerContext
|
||||||
{
|
{
|
||||||
public JTokenType Type { get; private set; }
|
public JTokenType Type { get; private set; }
|
||||||
@@ -79,10 +82,19 @@ namespace Newtonsoft.Json.Bson
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="BsonReader"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The stream.</param>
|
||||||
public BsonReader(Stream stream) : this(stream, false)
|
public BsonReader(Stream stream) : this(stream, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="BsonReader"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The stream.</param>
|
||||||
|
/// <param name="rootTypeIsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
|
||||||
public BsonReader(Stream stream, bool rootTypeIsArray)
|
public BsonReader(Stream stream, bool rootTypeIsArray)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(stream, "stream");
|
ValidationUtils.ArgumentNotNull(stream, "stream");
|
||||||
@@ -98,6 +110,12 @@ namespace Newtonsoft.Json.Bson
|
|||||||
return elementName;
|
return elementName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="T:Byte[]"/> or a null reference if the next JSON token is null.
|
||||||
|
/// </returns>
|
||||||
public override byte[] ReadAsBytes()
|
public override byte[] ReadAsBytes()
|
||||||
{
|
{
|
||||||
Read();
|
Read();
|
||||||
@@ -107,6 +125,12 @@ namespace Newtonsoft.Json.Bson
|
|||||||
return (byte[])Value;
|
return (byte[])Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// true if the next token was read successfully; false if there are no more tokens to read.
|
||||||
|
/// </returns>
|
||||||
public override bool Read()
|
public override bool Read()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -24,28 +24,34 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json.Utilities;
|
using Newtonsoft.Json.Utilities;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Bson
|
namespace Newtonsoft.Json.Bson
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
|
||||||
|
/// </summary>
|
||||||
public class BsonWriter : JTokenWriter
|
public class BsonWriter : JTokenWriter
|
||||||
{
|
{
|
||||||
private readonly Stream _stream;
|
|
||||||
private readonly BinaryWriter _writer;
|
private readonly BinaryWriter _writer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="BsonWriter"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The stream.</param>
|
||||||
public BsonWriter(Stream stream)
|
public BsonWriter(Stream stream)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(stream, "stream");
|
ValidationUtils.ArgumentNotNull(stream, "stream");
|
||||||
_stream = stream;
|
|
||||||
_writer = new BinaryWriter(stream);
|
_writer = new BinaryWriter(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
|
||||||
|
/// </summary>
|
||||||
public override void Flush()
|
public override void Flush()
|
||||||
{
|
{
|
||||||
_writer.Flush();
|
_writer.Flush();
|
||||||
@@ -76,7 +82,7 @@ namespace Newtonsoft.Json.Bson
|
|||||||
foreach (JToken c in t)
|
foreach (JToken c in t)
|
||||||
{
|
{
|
||||||
_writer.Write((sbyte)GetTypeNumber(c));
|
_writer.Write((sbyte)GetTypeNumber(c));
|
||||||
WriteString(index.ToString());
|
WriteString(index.ToString(CultureInfo.InvariantCulture));
|
||||||
WriteToken(c);
|
WriteToken(c);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -84,10 +90,10 @@ namespace Newtonsoft.Json.Bson
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JTokenType.Integer:
|
case JTokenType.Integer:
|
||||||
_writer.Write(Convert.ToInt32(((JValue)t).Value));
|
_writer.Write(Convert.ToInt32(((JValue)t).Value, CultureInfo.InvariantCulture));
|
||||||
break;
|
break;
|
||||||
case JTokenType.Float:
|
case JTokenType.Float:
|
||||||
_writer.Write(Convert.ToDouble(((JValue)t).Value));
|
_writer.Write(Convert.ToDouble(((JValue)t).Value, CultureInfo.InvariantCulture));
|
||||||
break;
|
break;
|
||||||
case JTokenType.String:
|
case JTokenType.String:
|
||||||
WriteStringWithLength((string)t);
|
WriteStringWithLength((string)t);
|
||||||
@@ -201,7 +207,7 @@ namespace Newtonsoft.Json.Bson
|
|||||||
foreach (JToken c in t)
|
foreach (JToken c in t)
|
||||||
{
|
{
|
||||||
bases += 1;
|
bases += 1;
|
||||||
bases += CalculateSize(index.ToString());
|
bases += CalculateSize(index.ToString(CultureInfo.InvariantCulture));
|
||||||
bases += CalculateSize(c);
|
bases += CalculateSize(c);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -243,6 +249,10 @@ namespace Newtonsoft.Json.Bson
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the end.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token">The token.</param>
|
||||||
protected override void WriteEnd(JsonToken token)
|
protected override void WriteEnd(JsonToken token)
|
||||||
{
|
{
|
||||||
base.WriteEnd(token);
|
base.WriteEnd(token);
|
||||||
|
|||||||
@@ -32,8 +32,17 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Converters
|
namespace Newtonsoft.Json.Converters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a <see cref="DataSet"/> to and from JSON.
|
||||||
|
/// </summary>
|
||||||
public class DataSetConverter : JsonConverter
|
public class DataSetConverter : JsonConverter
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the JSON representation of the object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
DataSet dataSet = (DataSet)value;
|
DataSet dataSet = (DataSet)value;
|
||||||
@@ -52,6 +61,13 @@ namespace Newtonsoft.Json.Converters
|
|||||||
writer.WriteEndObject();
|
writer.WriteEndObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the JSON representation of the object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
DataSet ds = new DataSet();
|
DataSet ds = new DataSet();
|
||||||
@@ -71,6 +87,13 @@ namespace Newtonsoft.Json.Converters
|
|||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether this instance can convert the specified value type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="valueType">Type of the value.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <c>true</c> if this instance can convert the specified value type; otherwise, <c>false</c>.
|
||||||
|
/// </returns>
|
||||||
public override bool CanConvert(Type valueType)
|
public override bool CanConvert(Type valueType)
|
||||||
{
|
{
|
||||||
return (valueType == typeof(DataSet));
|
return (valueType == typeof(DataSet));
|
||||||
|
|||||||
@@ -32,8 +32,17 @@ using System.Data;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Converters
|
namespace Newtonsoft.Json.Converters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a <see cref="DataTable"/> to and from JSON.
|
||||||
|
/// </summary>
|
||||||
public class DataTableConverter : JsonConverter
|
public class DataTableConverter : JsonConverter
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the JSON representation of the object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
DataTable table = (DataTable)value;
|
DataTable table = (DataTable)value;
|
||||||
@@ -54,6 +63,13 @@ namespace Newtonsoft.Json.Converters
|
|||||||
writer.WriteEndArray();
|
writer.WriteEndArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the JSON representation of the object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
|
||||||
|
/// <param name="objectType">Type of the object.</param>
|
||||||
|
/// <param name="serializer">The calling serializer.</param>
|
||||||
|
/// <returns>The object value.</returns>
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
DataTable dt;
|
DataTable dt;
|
||||||
@@ -123,6 +139,13 @@ namespace Newtonsoft.Json.Converters
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether this instance can convert the specified value type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="valueType">Type of the value.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <c>true</c> if this instance can convert the specified value type; otherwise, <c>false</c>.
|
||||||
|
/// </returns>
|
||||||
public override bool CanConvert(Type valueType)
|
public override bool CanConvert(Type valueType)
|
||||||
{
|
{
|
||||||
return (valueType == typeof(DataTable));
|
return (valueType == typeof(DataTable));
|
||||||
|
|||||||
@@ -204,6 +204,10 @@ namespace Newtonsoft.Json
|
|||||||
/// <returns>true if the next token was read successfully; false if there are no more tokens to read.</returns>
|
/// <returns>true if the next token was read successfully; false if there are no more tokens to read.</returns>
|
||||||
public abstract bool Read();
|
public abstract bool Read();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="T:Byte[]"/> or a null reference if the next JSON token is null.</returns>
|
||||||
public abstract byte[] ReadAsBytes();
|
public abstract byte[] ReadAsBytes();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -327,6 +327,12 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="T:Byte[]"/> or a null reference if the next JSON token is null.
|
||||||
|
/// </returns>
|
||||||
public override byte[] ReadAsBytes()
|
public override byte[] ReadAsBytes()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|||||||
@@ -431,6 +431,10 @@ namespace Newtonsoft.Json
|
|||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Date);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes a <see cref="T:Byte[]"/> value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The <see cref="T:Byte[]"/> value to write.</param>
|
||||||
public override void WriteValue(byte[] value)
|
public override void WriteValue(byte[] value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
base.WriteValue(value);
|
||||||
|
|||||||
@@ -304,6 +304,12 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="T:Byte[]"/> or a null reference if the next JSON token is null.
|
||||||
|
/// </returns>
|
||||||
public override byte[] ReadAsBytes()
|
public override byte[] ReadAsBytes()
|
||||||
{
|
{
|
||||||
byte[] data = _reader.ReadAsBytes();
|
byte[] data = _reader.ReadAsBytes();
|
||||||
|
|||||||
@@ -975,6 +975,10 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes a <see cref="T:Byte[]"/> value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The <see cref="T:Byte[]"/> value to write.</param>
|
||||||
public virtual void WriteValue(byte[] value)
|
public virtual void WriteValue(byte[] value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
|
|||||||
@@ -742,6 +742,11 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return Convert.ToUInt64(v.Value, CultureInfo.InvariantCulture);
|
return Convert.ToUInt64(v.Value, CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an explicit conversion from <see cref="Newtonsoft.Json.Linq.JToken"/> to <see cref="T:System.Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static explicit operator byte[](JToken value)
|
public static explicit operator byte[](JToken value)
|
||||||
{
|
{
|
||||||
JValue v = EnsureValue(value);
|
JValue v = EnsureValue(value);
|
||||||
@@ -987,6 +992,11 @@ namespace Newtonsoft.Json.Linq
|
|||||||
return new JValue(value);
|
return new JValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an implicit conversion from <see cref="T:System.Byte[]"/> to <see cref="Newtonsoft.Json.Linq.JToken"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value to create a <see cref="JValue"/> from.</param>
|
||||||
|
/// <returns>The <see cref="JValue"/> initialized with the specified value.</returns>
|
||||||
public static implicit operator JToken(byte[] value)
|
public static implicit operator JToken(byte[] value)
|
||||||
{
|
{
|
||||||
return new JValue(value);
|
return new JValue(value);
|
||||||
@@ -1123,11 +1133,32 @@ namespace Newtonsoft.Json.Linq
|
|||||||
get { return _linePosition ?? 0; }
|
get { return _linePosition ?? 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects the token that matches the object path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">
|
||||||
|
/// The object path from the current <see cref="JToken"/> to the <see cref="JToken"/>
|
||||||
|
/// to be returned. This must be a string of property names or array indexes separated
|
||||||
|
/// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or
|
||||||
|
/// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The <see cref="JToken"/> that matches the object path or a null reference if no matching token is found.</returns>
|
||||||
public JToken SelectToken(string path)
|
public JToken SelectToken(string path)
|
||||||
{
|
{
|
||||||
return SelectToken(path, false);
|
return SelectToken(path, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects the token that matches the object path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">
|
||||||
|
/// The object path from the current <see cref="JToken"/> to the <see cref="JToken"/>
|
||||||
|
/// to be returned. This must be a string of property names or array indexes separated
|
||||||
|
/// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or
|
||||||
|
/// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="errorWhenNoMatch">A flag to indicate whether an error should be thrown if no token is found.</param>
|
||||||
|
/// <returns>The <see cref="JToken"/> that matches the object path.</returns>
|
||||||
public JToken SelectToken(string path, bool errorWhenNoMatch)
|
public JToken SelectToken(string path, bool errorWhenNoMatch)
|
||||||
{
|
{
|
||||||
JPath p = new JPath(path);
|
JPath p = new JPath(path);
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ namespace Newtonsoft.Json.Linq
|
|||||||
_current = token;
|
_current = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the next JSON token from the stream as a <see cref="T:Byte[]"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="T:Byte[]"/> or a null reference if the next JSON token is null.
|
||||||
|
/// </returns>
|
||||||
public override byte[] ReadAsBytes()
|
public override byte[] ReadAsBytes()
|
||||||
{
|
{
|
||||||
Read();
|
Read();
|
||||||
|
|||||||
@@ -23,11 +23,6 @@
|
|||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Linq
|
namespace Newtonsoft.Json.Linq
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -91,6 +86,9 @@ namespace Newtonsoft.Json.Linq
|
|||||||
/// A raw JSON value.
|
/// A raw JSON value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Raw,
|
Raw,
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of bytes value.
|
||||||
|
/// </summary>
|
||||||
Bytes
|
Bytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,6 +346,10 @@ namespace Newtonsoft.Json.Linq
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes a <see cref="T:Byte[]"/> value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The <see cref="T:Byte[]"/> value to write.</param>
|
||||||
public override void WriteValue(byte[] value)
|
public override void WriteValue(byte[] value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
base.WriteValue(value);
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
namespace Newtonsoft.Json
|
namespace Newtonsoft.Json
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicating whether a property is required.
|
||||||
|
/// </summary>
|
||||||
public enum Required
|
public enum Required
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The property is not required. The default state.
|
||||||
|
/// </summary>
|
||||||
Default,
|
Default,
|
||||||
|
/// <summary>
|
||||||
|
/// The property must be defined in JSON but can be a null value.
|
||||||
|
/// </summary>
|
||||||
AllowNull,
|
AllowNull,
|
||||||
|
/// <summary>
|
||||||
|
/// The property must be defined in JSON and cannot be a null value.
|
||||||
|
/// </summary>
|
||||||
Always
|
Always
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,29 @@
|
|||||||
#if !PocketPC
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#if !PocketPC
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -9,18 +34,30 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Serialization
|
namespace Newtonsoft.Json.Serialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get and set values for a <see cref="MemberInfo"/> using dynamic methods.
|
||||||
|
/// </summary>
|
||||||
public class DynamicValueProvider : IValueProvider
|
public class DynamicValueProvider : IValueProvider
|
||||||
{
|
{
|
||||||
private readonly MemberInfo _memberInfo;
|
private readonly MemberInfo _memberInfo;
|
||||||
private Func<object, object> _getter;
|
private Func<object, object> _getter;
|
||||||
private Action<object, object> _setter;
|
private Action<object, object> _setter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DynamicValueProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="memberInfo">The member info.</param>
|
||||||
public DynamicValueProvider(MemberInfo memberInfo)
|
public DynamicValueProvider(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo");
|
ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo");
|
||||||
_memberInfo = memberInfo;
|
_memberInfo = memberInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to set the value on.</param>
|
||||||
|
/// <param name="value">The value to set on the target.</param>
|
||||||
public void SetValue(object target, object value)
|
public void SetValue(object target, object value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -36,6 +73,11 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to get the value from.</param>
|
||||||
|
/// <returns>The value.</returns>
|
||||||
public object GetValue(object target)
|
public object GetValue(object target)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,13 +1,47 @@
|
|||||||
using System;
|
#region License
|
||||||
using System.Collections.Generic;
|
// Copyright (c) 2007 James Newton-King
|
||||||
using System.Linq;
|
//
|
||||||
using System.Text;
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Serialization
|
namespace Newtonsoft.Json.Serialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods to get and set values.
|
||||||
|
/// </summary>
|
||||||
public interface IValueProvider
|
public interface IValueProvider
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to set the value on.</param>
|
||||||
|
/// <param name="value">The value to set on the target.</param>
|
||||||
void SetValue(object target, object value);
|
void SetValue(object target, object value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to get the value from.</param>
|
||||||
|
/// <returns>The value.</returns>
|
||||||
object GetValue(object target);
|
object GetValue(object target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,16 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
public MethodInfo OnSerializing { get; set; }
|
public MethodInfo OnSerializing { get; set; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the default creator.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The default creator.</value>
|
||||||
public Func<object> DefaultCreator { get; set; }
|
public Func<object> DefaultCreator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether [default creator non public].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if the default object creator is non-public; otherwise, <c>false</c>.</value>
|
||||||
public bool DefaultCreatorNonPublic { get; set; }
|
public bool DefaultCreatorNonPublic { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Serialization
|
namespace Newtonsoft.Json.Serialization
|
||||||
@@ -45,8 +44,16 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
|
/// <value>The <see cref="IValueProvider"/> that will get and set the <see cref="JsonProperty"/> during serialization.</value>
|
||||||
public IValueProvider ValueProvider { get; set; }
|
public IValueProvider ValueProvider { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the type of the property.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The type of the property.</value>
|
||||||
public Type PropertyType { get; set; }
|
public Type PropertyType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the converter.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The converter.</value>
|
||||||
public JsonConverter Converter { get; set; }
|
public JsonConverter Converter { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
{
|
{
|
||||||
private readonly JsonObjectContract _contract;
|
private readonly JsonObjectContract _contract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="JsonPropertyCollection"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="contract">The contract.</param>
|
||||||
public JsonPropertyCollection(JsonObjectContract contract)
|
public JsonPropertyCollection(JsonObjectContract contract)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(contract, "contract");
|
ValidationUtils.ArgumentNotNull(contract, "contract");
|
||||||
|
|||||||
@@ -1,4 +1,29 @@
|
|||||||
using System;
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -8,16 +33,28 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Serialization
|
namespace Newtonsoft.Json.Serialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get and set values for a <see cref="MemberInfo"/> using reflection.
|
||||||
|
/// </summary>
|
||||||
public class ReflectionValueProvider : IValueProvider
|
public class ReflectionValueProvider : IValueProvider
|
||||||
{
|
{
|
||||||
private readonly MemberInfo _memberInfo;
|
private readonly MemberInfo _memberInfo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ReflectionValueProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="memberInfo">The member info.</param>
|
||||||
public ReflectionValueProvider(MemberInfo memberInfo)
|
public ReflectionValueProvider(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo");
|
ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo");
|
||||||
_memberInfo = memberInfo;
|
_memberInfo = memberInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to set the value on.</param>
|
||||||
|
/// <param name="value">The value to set on the target.</param>
|
||||||
public void SetValue(object target, object value)
|
public void SetValue(object target, object value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -30,6 +67,11 @@ namespace Newtonsoft.Json.Serialization
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target to get the value from.</param>
|
||||||
|
/// <returns>The value.</returns>
|
||||||
public object GetValue(object target)
|
public object GetValue(object target)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Utilities
|
namespace Newtonsoft.Json.Utilities
|
||||||
{
|
{
|
||||||
public class DynamicWrapperBase
|
internal class DynamicWrapperBase
|
||||||
{
|
{
|
||||||
internal protected object UnderlyingObject;
|
internal protected object UnderlyingObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DynamicWrapper
|
internal static class DynamicWrapper
|
||||||
{
|
{
|
||||||
private static readonly object _lock = new object();
|
private static readonly object _lock = new object();
|
||||||
private static readonly WrapperDictionary _wrapperDictionary = new WrapperDictionary();
|
private static readonly WrapperDictionary _wrapperDictionary = new WrapperDictionary();
|
||||||
@@ -224,7 +224,7 @@ namespace Newtonsoft.Json.Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TypeExtensions
|
internal static class TypeExtensions
|
||||||
{
|
{
|
||||||
public static MethodInfo GetGenericMethod(this Type type, string name, params Type[] parameterTypes)
|
public static MethodInfo GetGenericMethod(this Type type, string name, params Type[] parameterTypes)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user