本文整理汇总了C#中MongoDB.Driver.SafeMode类的典型用法代码示例。如果您正苦于以下问题:C# SafeMode类的具体用法?C# SafeMode怎么用?C# SafeMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeMode类属于MongoDB.Driver命名空间,在下文中一共展示了SafeMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MongoInsertOptions
/// <summary>
/// Initializes a new instance of the MongoInsertOptions class.
/// </summary>
/// <param name="collection">The collection from which to get default settings for the options.</param>
public MongoInsertOptions(
MongoCollection collection
) {
this.checkElementNames = true;
this.flags = InsertFlags.None;
this.safeMode = collection.Settings.SafeMode;
}
示例2: MongoServerSettings
public MongoServerSettings(
ConnectionMode connectionMode,
TimeSpan connectTimeout,
MongoCredentials defaultCredentials,
TimeSpan maxConnectionIdleTime,
TimeSpan maxConnectionLifeTime,
int maxConnectionPoolSize,
int minConnectionPoolSize,
string replicaSetName,
SafeMode safeMode,
IEnumerable<MongoServerAddress> servers,
bool slaveOk,
TimeSpan socketTimeout,
int waitQueueSize,
TimeSpan waitQueueTimeout
)
{
this.connectionMode = connectionMode;
this.connectTimeout = connectTimeout;
this.defaultCredentials = defaultCredentials;
this.maxConnectionIdleTime = maxConnectionIdleTime;
this.maxConnectionLifeTime = maxConnectionLifeTime;
this.maxConnectionPoolSize = maxConnectionPoolSize;
this.minConnectionPoolSize = minConnectionPoolSize;
this.replicaSetName = replicaSetName;
this.safeMode = safeMode;
this.servers = servers;
this.slaveOk = slaveOk;
this.socketTimeout = socketTimeout;
this.waitQueueSize = waitQueueSize;
this.waitQueueTimeout = waitQueueTimeout;
}
示例3: MongoDatabaseSettings
public MongoDatabaseSettings()
{
this.databaseName = null;
this.credentials = null;
this.safeMode = SafeMode.False;
this.slaveOk = false;
}
示例4: MongoDatabaseSettings
/// <summary>
/// Creates a new instance of MongoDatabaseSettings.
/// </summary>
/// <param name="databaseName">The name of the database.</param>
/// <param name="credentials">The credentials to access the database.</param>
/// <param name="guidRepresentation">The representation for Guids.</param>
/// <param name="readPreference">The read preference.</param>
/// <param name="safeMode">The safe mode to use.</param>
public MongoDatabaseSettings(
string databaseName,
MongoCredentials credentials,
GuidRepresentation guidRepresentation,
ReadPreference readPreference,
SafeMode safeMode)
{
if (databaseName == null)
{
throw new ArgumentNullException("databaseName");
}
if (databaseName == "admin" && credentials != null && !credentials.Admin)
{
throw new ArgumentOutOfRangeException("Credentials for the admin database must have the admin flag set to true.");
}
if (readPreference == null)
{
throw new ArgumentNullException("readPreference");
}
if (safeMode == null)
{
throw new ArgumentNullException("safeMode");
}
_databaseName = databaseName;
_credentials = credentials;
_guidRepresentation = guidRepresentation;
_readPreference = readPreference;
_safeMode = safeMode;
}
示例5: MongoDatabaseSettings
/// <summary>
/// Creates a new instance of MongoDatabaseSettings.
/// </summary>
/// <param name="databaseName">The name of the database.</param>
/// <param name="credentials">The credentials to access the database.</param>
/// <param name="guidRepresentation">The representation for Guids.</param>
/// <param name="safeMode">The safe mode to use.</param>
/// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
public MongoDatabaseSettings(string databaseName, MongoCredentials credentials, GuidRepresentation guidRepresentation, SafeMode safeMode, bool slaveOk)
{
_databaseName = databaseName;
_credentials = credentials;
_guidRepresentation = guidRepresentation;
_safeMode = safeMode;
_slaveOk = slaveOk;
}
示例6: MongoDatabaseSettings
/// <summary>
/// Creates a new instance of MongoDatabaseSettings.
/// </summary>
/// <param name="databaseName">The name of the database.</param>
/// <param name="credentials">The credentials to access the database.</param>
/// <param name="guidRepresentation">The representation for Guids.</param>
/// <param name="safeMode">The safe mode to use.</param>
/// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
public MongoDatabaseSettings(string databaseName, MongoCredentials credentials, GuidRepresentation guidRepresentation, SafeMode safeMode, ReadPreference readPreference)
{
this.databaseName = databaseName;
this.credentials = credentials;
this.guidRepresentation = guidRepresentation;
this.safeMode = safeMode;
this.readPreference = readPreference;
}
示例7: MongoCollectionSettings
public MongoCollectionSettings()
{
this.collectionName = null;
this.assignIdOnInsert = true;
this.defaultDocumentType = typeof(BsonDocument);
this.safeMode = SafeMode.False;
this.slaveOk = false;
}
示例8: MongoDatabaseSettings
// constructors
/// <summary>
/// Creates a new instance of MongoDatabaseSettings.
/// </summary>
/// <param name="server">The server to inherit settings from.</param>
/// <param name="databaseName">The name of the database.</param>
public MongoDatabaseSettings(MongoServer server, string databaseName)
{
var serverSettings = server.Settings;
_databaseName = databaseName;
_credentials = serverSettings.DefaultCredentials;
_guidRepresentation = serverSettings.GuidRepresentation;
_safeMode = serverSettings.SafeMode;
_slaveOk = serverSettings.SlaveOk;
}
示例9: MongoCollectionSettings
// constructors
/// <summary>
/// Initializes a new instance of the MongoCollectionSettings class.
/// </summary>
/// <param name="database">The database that contains the collection (some collection settings will be inherited from the database settings).</param>
/// <param name="collectionName">The name of the collection.</param>
/// <param name="defaultDocumentType">The default document type for the collection.</param>
protected MongoCollectionSettings(MongoDatabase database, string collectionName, Type defaultDocumentType)
{
var databaseSettings = database.Settings;
_collectionName = collectionName;
_assignIdOnInsert = MongoDefaults.AssignIdOnInsert;
_defaultDocumentType = defaultDocumentType;
_guidRepresentation = databaseSettings.GuidRepresentation;
_safeMode = databaseSettings.SafeMode;
_slaveOk = databaseSettings.SlaveOk;
}
示例10: TestCreateWithEnabledAndFSync
public void TestCreateWithEnabledAndFSync()
{
var safeMode = new SafeMode(true, true);
Assert.AreEqual(true, safeMode.Enabled);
Assert.AreEqual(true, safeMode.FSync);
Assert.AreEqual(false, safeMode.Journal);
Assert.AreEqual(0, safeMode.W);
Assert.AreEqual(null, safeMode.WMode);
Assert.AreEqual(TimeSpan.Zero, safeMode.WTimeout);
}
示例11: TestCreateWithW
public void TestCreateWithW()
{
var safeMode = new SafeMode(2);
Assert.AreEqual(true, safeMode.Enabled);
Assert.AreEqual(false, safeMode.FSync);
Assert.AreEqual(false, safeMode.J);
Assert.AreEqual(2, safeMode.W);
Assert.AreEqual(null, safeMode.WMode);
Assert.AreEqual(TimeSpan.Zero, safeMode.WTimeout);
}
示例12: TestCreateWithEnabledAndFSyncAndWAndWTimeout
public void TestCreateWithEnabledAndFSyncAndWAndWTimeout()
{
var safeMode = new SafeMode(true, true, 2, TimeSpan.FromSeconds(30));
Assert.AreEqual(true, safeMode.Enabled);
Assert.AreEqual(true, safeMode.FSync);
Assert.AreEqual(false, safeMode.J);
Assert.AreEqual(2, safeMode.W);
Assert.AreEqual(null, safeMode.WMode);
Assert.AreEqual(TimeSpan.FromSeconds(30), safeMode.WTimeout);
}
示例13: MongoDatabaseSettings
/// <summary>
/// Creates a new instance of MongoDatabaseSettings. Usually you would call MongoServer.CreateDatabaseSettings instead.
/// </summary>
/// <param name="databaseName">The name of the database.</param>
/// <param name="credentials">The credentials to access the database.</param>
/// <param name="safeMode">The safe mode to use.</param>
/// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
public MongoDatabaseSettings(
string databaseName,
MongoCredentials credentials,
SafeMode safeMode,
bool slaveOk
) {
this.databaseName = databaseName;
this.credentials = credentials;
this.safeMode = safeMode;
this.slaveOk = slaveOk;
}
示例14: MongoDatabaseSettings
/// <summary>
/// Creates a new instance of MongoDatabaseSettings. Usually you would call MongoServer.CreateDatabaseSettings instead.
/// </summary>
/// <param name="databaseName">The name of the database.</param>
/// <param name="credentials">The credentials to access the database.</param>
/// <param name="guidRepresentation">The representation for Guids.</param>
/// <param name="safeMode">The safe mode to use.</param>
/// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
public MongoDatabaseSettings(
string databaseName,
MongoCredentials credentials,
GuidRepresentation guidRepresentation,
SafeMode safeMode,
bool slaveOk
) {
this.databaseName = databaseName;
this.credentials = credentials;
this.guidRepresentation = guidRepresentation;
this.safeMode = safeMode;
this.slaveOk = slaveOk;
}
示例15: MongoCollectionSettings
protected MongoCollectionSettings(
string collectionName,
bool assignIdOnInsert,
Type defaultDocumentType,
SafeMode safeMode,
bool slaveOk
) {
this.collectionName = collectionName;
this.assignIdOnInsert = assignIdOnInsert;
this.defaultDocumentType = defaultDocumentType;
this.safeMode = safeMode;
this.slaveOk = slaveOk;
}