Browse Source

Delayed creation of default settings objects so that they are created with the latest lower level default values. Moved GuidByteOrder to its own file. MongoDefaults that have matching BsonDefaults are now aliases for the corresponding BsonDefaults (that way the values are always the same).

pull/62/merge
rstam 14 years ago
parent
commit
99123333a1
  1. 1
      Bson/Bson.csproj
  2. 9
      Bson/IO/BsonBinaryReaderSettings.cs
  3. 9
      Bson/IO/BsonBinaryWriterSettings.cs
  4. 9
      Bson/IO/BsonDocumentReaderSettings.cs
  5. 9
      Bson/IO/BsonDocumentWriterSettings.cs
  6. 9
      Bson/IO/JsonReaderSettings.cs
  7. 9
      Bson/IO/JsonWriterSettings.cs
  8. 22
      Bson/ObjectModel/BsonBinaryData.cs
  9. 43
      Bson/ObjectModel/GuidByteOrder.cs
  10. 14
      Driver/MongoDefaults.cs

1
Bson/Bson.csproj

@ -83,6 +83,7 @@
<Compile Include="BsonExtensionMethods.cs" />
<Compile Include="IO\BsonDocumentReaderSettings.cs" />
<Compile Include="IO\BsonDocumentWriterSettings.cs" />
<Compile Include="ObjectModel\GuidByteOrder.cs" />
<Compile Include="ObjectModel\GuidConverter.cs" />
<Compile Include="IO\JsonReaderSettings.cs" />
<Compile Include="Serialization\Attributes\BsonDateTimeOptionsAttribute.cs" />

9
Bson/IO/BsonBinaryReaderSettings.cs

@ -24,7 +24,7 @@ namespace MongoDB.Bson.IO {
/// </summary>
public class BsonBinaryReaderSettings {
#region private static fields
private static BsonBinaryReaderSettings defaults = new BsonBinaryReaderSettings();
private static BsonBinaryReaderSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -67,7 +67,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default settings for a BsonBinaryReader.
/// </summary>
public static BsonBinaryReaderSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new BsonBinaryReaderSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

9
Bson/IO/BsonBinaryWriterSettings.cs

@ -25,7 +25,7 @@ namespace MongoDB.Bson.IO {
[Serializable]
public class BsonBinaryWriterSettings {
#region private static fields
private static BsonBinaryWriterSettings defaults = new BsonBinaryWriterSettings();
private static BsonBinaryWriterSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -68,7 +68,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default BsonBinaryWriter settings.
/// </summary>
public static BsonBinaryWriterSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new BsonBinaryWriterSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

9
Bson/IO/BsonDocumentReaderSettings.cs

@ -24,7 +24,7 @@ namespace MongoDB.Bson.IO {
/// </summary>
public class BsonDocumentReaderSettings {
#region private static fields
private static BsonDocumentReaderSettings defaults = new BsonDocumentReaderSettings();
private static BsonDocumentReaderSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -55,7 +55,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default settings for a BsonDocumentReader.
/// </summary>
public static BsonDocumentReaderSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new BsonDocumentReaderSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

9
Bson/IO/BsonDocumentWriterSettings.cs

@ -25,7 +25,7 @@ namespace MongoDB.Bson.IO {
[Serializable]
public class BsonDocumentWriterSettings {
#region private static fields
private static BsonDocumentWriterSettings defaults = new BsonDocumentWriterSettings();
private static BsonDocumentWriterSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -56,7 +56,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default BsonDocumentWriter settings.
/// </summary>
public static BsonDocumentWriterSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new BsonDocumentWriterSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

9
Bson/IO/JsonReaderSettings.cs

@ -24,7 +24,7 @@ namespace MongoDB.Bson.IO {
/// </summary>
public class JsonReaderSettings {
#region private static fields
private static JsonReaderSettings defaults = new JsonReaderSettings();
private static JsonReaderSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -59,7 +59,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default settings for a JsonReader.
/// </summary>
public static JsonReaderSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new JsonReaderSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

9
Bson/IO/JsonWriterSettings.cs

@ -25,7 +25,7 @@ namespace MongoDB.Bson.IO {
[Serializable]
public class JsonWriterSettings {
#region private static fields
private static JsonWriterSettings defaults = new JsonWriterSettings();
private static JsonWriterSettings defaults = null; // delay creation to pick up the latest default values
#endregion
#region private fields
@ -77,7 +77,12 @@ namespace MongoDB.Bson.IO {
/// Gets or sets the default JsonWriterSettings.
/// </summary>
public static JsonWriterSettings Defaults {
get { return defaults; }
get {
if (defaults == null) {
defaults = new JsonWriterSettings();
}
return defaults;
}
set { defaults = value; }
}
#endregion

22
Bson/ObjectModel/BsonBinaryData.cs

@ -19,28 +19,6 @@ using System.Linq;
using System.Text;
namespace MongoDB.Bson {
/// <summary>
/// Represents the byte order to use when representing a Guid as a byte array.
/// </summary>
public enum GuidByteOrder {
/// <summary>
/// The byte order for Guids is unspecified, so no conversion between byte arrays and Guids is not possible.
/// </summary>
Unspecified,
/// <summary>
/// Use Microsoft's internal little endian format (this is the default for historical reasons, but is different from how the Java and other drivers store UUIDs).
/// </summary>
LittleEndian,
/// <summary>
/// Use the standard external high endian format (this is compatible with how the Java and other drivers store UUIDs).
/// </summary>
BigEndian,
/// <summary>
/// Use the byte order used by older versions of the Java driver (two 8 byte halves in little endian order).
/// </summary>
JavaHistorical
}
/// <summary>
/// Represents BSON binary data.
/// </summary>

43
Bson/ObjectModel/GuidByteOrder.cs

@ -0,0 +1,43 @@
/* Copyright 2010-2011 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MongoDB.Bson {
/// <summary>
/// Represents the byte order to use when representing a Guid as a byte array.
/// </summary>
public enum GuidByteOrder {
/// <summary>
/// The byte order for Guids is unspecified, so conversion between byte arrays and Guids is not possible.
/// </summary>
Unspecified,
/// <summary>
/// Use Microsoft's internal little endian format (this is the default for historical reasons, but is different from how the Java and other drivers store UUIDs).
/// </summary>
LittleEndian,
/// <summary>
/// Use the standard external high endian format (this is compatible with how the Java and other drivers store UUIDs).
/// </summary>
BigEndian,
/// <summary>
/// Use the byte order used by older versions of the Java driver (two 8 byte halves in little endian order).
/// </summary>
JavaHistorical
}
}

14
Driver/MongoDefaults.cs

@ -29,11 +29,9 @@ namespace MongoDB.Driver {
#region public static fields
private static bool assignIdOnInsert = true;
private static TimeSpan connectTimeout = TimeSpan.FromSeconds(30);
private static GuidByteOrder guidByteOrder = GuidByteOrder.LittleEndian;
private static TimeSpan maxConnectionIdleTime = TimeSpan.FromMinutes(10);
private static TimeSpan maxConnectionLifeTime = TimeSpan.FromMinutes(30);
private static int maxConnectionPoolSize = 100;
private static int maxDocumentSize = BsonDefaults.MaxDocumentSize;
private static int maxMessageLength = 16000000; // 16MB (not 16 MiB!)
private static int minConnectionPoolSize = 0;
private static SafeMode safeMode = SafeMode.False;
@ -76,11 +74,11 @@ namespace MongoDB.Driver {
}
/// <summary>
/// Gets or sets the byte order to use for Guids.
/// Gets or sets the byte order to use for Guids (this is an alias for BsonDefaults.GuidByteOrder).
/// </summary>
public static GuidByteOrder GuidByteOrder {
get { return guidByteOrder; }
set { guidByteOrder = value; }
get { return BsonDefaults.GuidByteOrder; }
set { BsonDefaults.GuidByteOrder = value; }
}
/// <summary>
@ -108,11 +106,11 @@ namespace MongoDB.Driver {
}
/// <summary>
/// Gets or sets the max document size.
/// Gets or sets the max document size (this is an alias for BsonDefaults.MaxDocumentSize).
/// </summary>
public static int MaxDocumentSize {
get { return maxDocumentSize; }
set { maxDocumentSize = value; }
get { return BsonDefaults.MaxDocumentSize; }
set { BsonDefaults.MaxDocumentSize = value; }
}
/// <summary>

Loading…
Cancel
Save