diff --git a/Src/Newtonsoft.Json/Bson/BsonReader.cs b/Src/Newtonsoft.Json/Bson/BsonReader.cs
index 2c068eb2..225d0fa8 100644
--- a/Src/Newtonsoft.Json/Bson/BsonReader.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonReader.cs
@@ -34,19 +34,9 @@ using Newtonsoft.Json.Linq;
namespace Newtonsoft.Json.Bson
{
- internal enum BsonReaderState
- {
- Normal,
- ReferenceStart,
- ReferenceRef,
- ReferenceId,
- CodeWScopeStart,
- CodeWScopeCode,
- CodeWScopeScope,
- CodeWScopeScopeObject,
- CodeWScopeScopeEnd
- }
-
+ ///
+ /// Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
+ ///
public class BsonReader : JsonReader
{
private readonly BinaryReader _reader;
@@ -56,6 +46,19 @@ namespace Newtonsoft.Json.Bson
private BsonType _currentElementType;
private BsonReaderState _bsonReaderState;
+ private enum BsonReaderState
+ {
+ Normal,
+ ReferenceStart,
+ ReferenceRef,
+ ReferenceId,
+ CodeWScopeStart,
+ CodeWScopeCode,
+ CodeWScopeScope,
+ CodeWScopeScopeObject,
+ CodeWScopeScopeEnd
+ }
+
private class ContainerContext
{
public JTokenType Type { get; private set; }
@@ -79,10 +82,19 @@ namespace Newtonsoft.Json.Bson
}
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The stream.
public BsonReader(Stream stream) : this(stream, false)
{
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The stream.
+ /// if set to true the root object will be read as a JSON array.
public BsonReader(Stream stream, bool rootTypeIsArray)
{
ValidationUtils.ArgumentNotNull(stream, "stream");
@@ -98,6 +110,12 @@ namespace Newtonsoft.Json.Bson
return elementName;
}
+ ///
+ /// Reads the next JSON token from the stream as a .
+ ///
+ ///
+ /// A or a null reference if the next JSON token is null.
+ ///
public override byte[] ReadAsBytes()
{
Read();
@@ -107,6 +125,12 @@ namespace Newtonsoft.Json.Bson
return (byte[])Value;
}
+ ///
+ /// Reads the next JSON token from the stream.
+ ///
+ ///
+ /// true if the next token was read successfully; false if there are no more tokens to read.
+ ///
public override bool Read()
{
try
diff --git a/Src/Newtonsoft.Json/Bson/BsonWriter.cs b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
index 755b135a..507fea14 100644
--- a/Src/Newtonsoft.Json/Bson/BsonWriter.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
@@ -24,28 +24,34 @@
#endregion
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq;
+using System.Globalization;
namespace Newtonsoft.Json.Bson
{
+ ///
+ /// Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.
+ ///
public class BsonWriter : JTokenWriter
{
- private readonly Stream _stream;
private readonly BinaryWriter _writer;
-
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The stream.
public BsonWriter(Stream stream)
{
ValidationUtils.ArgumentNotNull(stream, "stream");
- _stream = stream;
_writer = new BinaryWriter(stream);
}
+ ///
+ /// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
+ ///
public override void Flush()
{
_writer.Flush();
@@ -76,7 +82,7 @@ namespace Newtonsoft.Json.Bson
foreach (JToken c in t)
{
_writer.Write((sbyte)GetTypeNumber(c));
- WriteString(index.ToString());
+ WriteString(index.ToString(CultureInfo.InvariantCulture));
WriteToken(c);
index++;
}
@@ -84,10 +90,10 @@ namespace Newtonsoft.Json.Bson
}
break;
case JTokenType.Integer:
- _writer.Write(Convert.ToInt32(((JValue)t).Value));
+ _writer.Write(Convert.ToInt32(((JValue)t).Value, CultureInfo.InvariantCulture));
break;
case JTokenType.Float:
- _writer.Write(Convert.ToDouble(((JValue)t).Value));
+ _writer.Write(Convert.ToDouble(((JValue)t).Value, CultureInfo.InvariantCulture));
break;
case JTokenType.String:
WriteStringWithLength((string)t);
@@ -201,7 +207,7 @@ namespace Newtonsoft.Json.Bson
foreach (JToken c in t)
{
bases += 1;
- bases += CalculateSize(index.ToString());
+ bases += CalculateSize(index.ToString(CultureInfo.InvariantCulture));
bases += CalculateSize(c);
index++;
}
@@ -243,6 +249,10 @@ namespace Newtonsoft.Json.Bson
}
}
+ ///
+ /// Writes the end.
+ ///
+ /// The token.
protected override void WriteEnd(JsonToken token)
{
base.WriteEnd(token);
diff --git a/Src/Newtonsoft.Json/Converters/DataSetConverter.cs b/Src/Newtonsoft.Json/Converters/DataSetConverter.cs
index 6fe951a1..89b4833c 100644
--- a/Src/Newtonsoft.Json/Converters/DataSetConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/DataSetConverter.cs
@@ -32,8 +32,17 @@ using System.Text;
namespace Newtonsoft.Json.Converters
{
+ ///
+ /// Converts a to and from JSON.
+ ///
public class DataSetConverter : JsonConverter
{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
DataSet dataSet = (DataSet)value;
@@ -52,6 +61,13 @@ namespace Newtonsoft.Json.Converters
writer.WriteEndObject();
}
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The calling serializer.
+ /// The object value.
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
{
DataSet ds = new DataSet();
@@ -71,6 +87,13 @@ namespace Newtonsoft.Json.Converters
return ds;
}
+ ///
+ /// Determines whether this instance can convert the specified value type.
+ ///
+ /// Type of the value.
+ ///
+ /// true if this instance can convert the specified value type; otherwise, false.
+ ///
public override bool CanConvert(Type valueType)
{
return (valueType == typeof(DataSet));
diff --git a/Src/Newtonsoft.Json/Converters/DataTableConverter.cs b/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
index e207f8a4..7c04c55a 100644
--- a/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/DataTableConverter.cs
@@ -32,8 +32,17 @@ using System.Data;
namespace Newtonsoft.Json.Converters
{
+ ///
+ /// Converts a to and from JSON.
+ ///
public class DataTableConverter : JsonConverter
{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
DataTable table = (DataTable)value;
@@ -54,6 +63,13 @@ namespace Newtonsoft.Json.Converters
writer.WriteEndArray();
}
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The calling serializer.
+ /// The object value.
public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
{
DataTable dt;
@@ -123,6 +139,13 @@ namespace Newtonsoft.Json.Converters
}
}
+ ///
+ /// Determines whether this instance can convert the specified value type.
+ ///
+ /// Type of the value.
+ ///
+ /// true if this instance can convert the specified value type; otherwise, false.
+ ///
public override bool CanConvert(Type valueType)
{
return (valueType == typeof(DataTable));
diff --git a/Src/Newtonsoft.Json/JsonReader.cs b/Src/Newtonsoft.Json/JsonReader.cs
index 875a5ac9..c6a3b762 100644
--- a/Src/Newtonsoft.Json/JsonReader.cs
+++ b/Src/Newtonsoft.Json/JsonReader.cs
@@ -204,6 +204,10 @@ namespace Newtonsoft.Json
/// true if the next token was read successfully; false if there are no more tokens to read.
public abstract bool Read();
+ ///
+ /// Reads the next JSON token from the stream as a .
+ ///
+ /// A or a null reference if the next JSON token is null.
public abstract byte[] ReadAsBytes();
///
diff --git a/Src/Newtonsoft.Json/JsonTextReader.cs b/Src/Newtonsoft.Json/JsonTextReader.cs
index 00ce3f6d..373049d5 100644
--- a/Src/Newtonsoft.Json/JsonTextReader.cs
+++ b/Src/Newtonsoft.Json/JsonTextReader.cs
@@ -327,6 +327,12 @@ namespace Newtonsoft.Json
}
}
+ ///
+ /// Reads the next JSON token from the stream as a .
+ ///
+ ///
+ /// A or a null reference if the next JSON token is null.
+ ///
public override byte[] ReadAsBytes()
{
while (true)
diff --git a/Src/Newtonsoft.Json/JsonTextWriter.cs b/Src/Newtonsoft.Json/JsonTextWriter.cs
index ce2ee004..df444f76 100644
--- a/Src/Newtonsoft.Json/JsonTextWriter.cs
+++ b/Src/Newtonsoft.Json/JsonTextWriter.cs
@@ -431,6 +431,10 @@ namespace Newtonsoft.Json
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Date);
}
+ ///
+ /// Writes a value.
+ ///
+ /// The value to write.
public override void WriteValue(byte[] value)
{
base.WriteValue(value);
diff --git a/Src/Newtonsoft.Json/JsonValidatingReader.cs b/Src/Newtonsoft.Json/JsonValidatingReader.cs
index 2b958aa0..3498bbd1 100644
--- a/Src/Newtonsoft.Json/JsonValidatingReader.cs
+++ b/Src/Newtonsoft.Json/JsonValidatingReader.cs
@@ -304,6 +304,12 @@ namespace Newtonsoft.Json
}
}
+ ///
+ /// Reads the next JSON token from the stream as a .
+ ///
+ ///
+ /// A or a null reference if the next JSON token is null.
+ ///
public override byte[] ReadAsBytes()
{
byte[] data = _reader.ReadAsBytes();
diff --git a/Src/Newtonsoft.Json/JsonWriter.cs b/Src/Newtonsoft.Json/JsonWriter.cs
index eeabf6fe..09d2ec5e 100644
--- a/Src/Newtonsoft.Json/JsonWriter.cs
+++ b/Src/Newtonsoft.Json/JsonWriter.cs
@@ -975,6 +975,10 @@ namespace Newtonsoft.Json
}
#endif
+ ///
+ /// Writes a value.
+ ///
+ /// The value to write.
public virtual void WriteValue(byte[] value)
{
if (value == null)
diff --git a/Src/Newtonsoft.Json/Linq/JToken.cs b/Src/Newtonsoft.Json/Linq/JToken.cs
index 8587e5ed..d9d50e33 100644
--- a/Src/Newtonsoft.Json/Linq/JToken.cs
+++ b/Src/Newtonsoft.Json/Linq/JToken.cs
@@ -742,6 +742,11 @@ namespace Newtonsoft.Json.Linq
return Convert.ToUInt64(v.Value, CultureInfo.InvariantCulture);
}
+ ///
+ /// Performs an explicit conversion from to .
+ ///
+ /// The value.
+ /// The result of the conversion.
public static explicit operator byte[](JToken value)
{
JValue v = EnsureValue(value);
@@ -987,6 +992,11 @@ namespace Newtonsoft.Json.Linq
return new JValue(value);
}
+ ///
+ /// Performs an implicit conversion from to .
+ ///
+ /// The value to create a from.
+ /// The initialized with the specified value.
public static implicit operator JToken(byte[] value)
{
return new JValue(value);
@@ -1123,11 +1133,32 @@ namespace Newtonsoft.Json.Linq
get { return _linePosition ?? 0; }
}
+ ///
+ /// Selects the token that matches the object path.
+ ///
+ ///
+ /// The object path from the current to the
+ /// to be returned. This must be a string of property names or array indexes separated
+ /// by periods, such as Tables[0].DefaultView[0].Price in C# or
+ /// Tables(0).DefaultView(0).Price in Visual Basic.
+ ///
+ /// The that matches the object path or a null reference if no matching token is found.
public JToken SelectToken(string path)
{
return SelectToken(path, false);
}
+ ///
+ /// Selects the token that matches the object path.
+ ///
+ ///
+ /// The object path from the current to the
+ /// to be returned. This must be a string of property names or array indexes separated
+ /// by periods, such as Tables[0].DefaultView[0].Price in C# or
+ /// Tables(0).DefaultView(0).Price in Visual Basic.
+ ///
+ /// A flag to indicate whether an error should be thrown if no token is found.
+ /// The that matches the object path.
public JToken SelectToken(string path, bool errorWhenNoMatch)
{
JPath p = new JPath(path);
diff --git a/Src/Newtonsoft.Json/Linq/JTokenReader.cs b/Src/Newtonsoft.Json/Linq/JTokenReader.cs
index dc220420..011ec158 100644
--- a/Src/Newtonsoft.Json/Linq/JTokenReader.cs
+++ b/Src/Newtonsoft.Json/Linq/JTokenReader.cs
@@ -28,6 +28,12 @@ namespace Newtonsoft.Json.Linq
_current = token;
}
+ ///
+ /// Reads the next JSON token from the stream as a .
+ ///
+ ///
+ /// A or a null reference if the next JSON token is null.
+ ///
public override byte[] ReadAsBytes()
{
Read();
diff --git a/Src/Newtonsoft.Json/Linq/JTokenType.cs b/Src/Newtonsoft.Json/Linq/JTokenType.cs
index e20ce277..dafb7e12 100644
--- a/Src/Newtonsoft.Json/Linq/JTokenType.cs
+++ b/Src/Newtonsoft.Json/Linq/JTokenType.cs
@@ -23,11 +23,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
namespace Newtonsoft.Json.Linq
{
///
@@ -91,6 +86,9 @@ namespace Newtonsoft.Json.Linq
/// A raw JSON value.
///
Raw,
+ ///
+ /// A collection of bytes value.
+ ///
Bytes
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs
index baae1ed1..d9413a39 100644
--- a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs
+++ b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs
@@ -346,6 +346,10 @@ namespace Newtonsoft.Json.Linq
}
#endif
+ ///
+ /// Writes a value.
+ ///
+ /// The value to write.
public override void WriteValue(byte[] value)
{
base.WriteValue(value);
diff --git a/Src/Newtonsoft.Json/Required.cs b/Src/Newtonsoft.Json/Required.cs
index 5777a7c7..b48ba411 100644
--- a/Src/Newtonsoft.Json/Required.cs
+++ b/Src/Newtonsoft.Json/Required.cs
@@ -1,9 +1,21 @@
namespace Newtonsoft.Json
{
+ ///
+ /// Indicating whether a property is required.
+ ///
public enum Required
{
+ ///
+ /// The property is not required. The default state.
+ ///
Default,
+ ///
+ /// The property must be defined in JSON but can be a null value.
+ ///
AllowNull,
+ ///
+ /// The property must be defined in JSON and cannot be a null value.
+ ///
Always
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs b/Src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs
index 4b3b5673..d0ad41cb 100644
--- a/Src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs
+++ b/Src/Newtonsoft.Json/Serialization/DynamicValueProvider.cs
@@ -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.Collections.Generic;
using System.Linq;
@@ -9,18 +34,30 @@ using System.Globalization;
namespace Newtonsoft.Json.Serialization
{
+ ///
+ /// Get and set values for a using dynamic methods.
+ ///
public class DynamicValueProvider : IValueProvider
{
private readonly MemberInfo _memberInfo;
private Func