本文整理汇总了C#中WriteConcern类的典型用法代码示例。如果您正苦于以下问题:C# WriteConcern类的具体用法?C# WriteConcern怎么用?C# WriteConcern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WriteConcern类属于命名空间,在下文中一共展示了WriteConcern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BulkDeleteOperationArgs
// constructors
public BulkDeleteOperationArgs(
string collectionName,
string databaseName,
int maxBatchCount,
int maxBatchLength,
int maxDocumentSize,
int maxWireDocumentSize,
bool isOrdered,
BsonBinaryReaderSettings readerSettings,
IEnumerable<DeleteRequest> requests,
WriteConcern writeConcern,
BsonBinaryWriterSettings writerSettings)
: base(
collectionName,
databaseName,
maxBatchCount,
maxBatchLength,
maxDocumentSize,
maxWireDocumentSize,
isOrdered,
readerSettings,
requests.Cast<WriteRequest>(),
writeConcern,
writerSettings)
{
}
示例2: 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="writeConcern">The write concern to use.</param>
public MongoDatabaseSettings(
string databaseName,
MongoCredentials credentials,
GuidRepresentation guidRepresentation,
ReadPreference readPreference,
WriteConcern writeConcern)
{
if (databaseName == null)
{
throw new ArgumentNullException("databaseName");
}
if (databaseName == "admin" && credentials != null && !credentials.Admin)
{
throw new ArgumentOutOfRangeException("credentials", "Credentials for the admin database must have the admin flag set to true.");
}
if (readPreference == null)
{
throw new ArgumentNullException("readPreference");
}
if (writeConcern == null)
{
throw new ArgumentNullException("writeConcern");
}
_databaseName = databaseName;
_credentials = credentials;
_guidRepresentation = guidRepresentation;
_readPreference = readPreference;
_writeConcern = writeConcern;
}
示例3: MongoImpl
public MongoImpl(MongoServer connection, WriteConcern writeConcern)
{
this.writeConcern = writeConcern;
Helpers.Random.Value.NextBytes(initialValue);
collection =
connection.GetDatabase(typeof (SomeDocument).Name).GetCollection<SomeDocument>(typeof (SomeDocument).Name);
}
示例4: BulkMixedWriteOperation
// constructors
public BulkMixedWriteOperation(
Action<InsertRequest> assignId,
bool checkElementNames,
string collectionName,
string databaseName,
int maxBatchCount,
int maxBatchLength,
int maxDocumentSize,
int maxWireDocumentSize,
bool isOrdered,
BsonBinaryReaderSettings readerSettings,
IEnumerable<WriteRequest> requests,
WriteConcern writeConcern,
BsonBinaryWriterSettings writerSettings)
{
_assignId = assignId;
_checkElementNames = checkElementNames;
_collectionName = collectionName;
_databaseName = databaseName;
_maxBatchCount = maxBatchCount;
_maxBatchLength = maxBatchLength;
_maxDocumentSize = maxDocumentSize;
_maxWireDocumentSize = maxWireDocumentSize;
_isOrdered = isOrdered;
_readerSettings = readerSettings;
_requests = requests;
_writeConcern = writeConcern;
_writerSettings = writerSettings;
}
示例5: GridFSBucketOptions
/// <summary>
/// Initializes a new instance of the <see cref="GridFSBucketOptions"/> class.
/// </summary>
/// <param name="other">The other <see cref="GridFSBucketOptions.Immutable"/> from which to copy the values.</param>
public GridFSBucketOptions(GridFSBucketOptions.Immutable other)
{
_bucketName = other.BucketName;
_chunkSizeBytes = other.ChunkSizeBytes;
_readPreference = other.ReadPreference;
_writeConcern = other.WriteConcern;
}
示例6: MongoServerSettings
// constructors
/// <summary>
/// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
/// </summary>
public MongoServerSettings()
{
_connectionMode = ConnectionMode.Automatic;
_connectTimeout = MongoDefaults.ConnectTimeout;
_credentialsStore = new MongoCredentialsStore();
_defaultCredentials = null;
_guidRepresentation = MongoDefaults.GuidRepresentation;
_ipv6 = false;
_maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
_maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
_maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
_minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
_readPreference = ReadPreference.Primary;
_replicaSetName = null;
_secondaryAcceptableLatency = MongoDefaults.SecondaryAcceptableLatency;
_servers = new List<MongoServerAddress> { new MongoServerAddress("localhost") };
_socketTimeout = MongoDefaults.SocketTimeout;
_useSsl = false;
_verifySslCertificate = true;
_waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
_waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
#pragma warning disable 612, 618
_writeConcern = MongoDefaults.SafeMode.WriteConcern;
#pragma warning restore
}
示例7: BulkWriteOperationArgs
// constructors
protected BulkWriteOperationArgs(
string collectionName,
string databaseName,
int maxBatchCount,
int maxBatchLength,
int maxDocumentSize,
int maxWireDocumentSize,
bool isOrdered,
BsonBinaryReaderSettings readerSettings,
IEnumerable<WriteRequest> requests,
WriteConcern writeConcern,
BsonBinaryWriterSettings writerSettings)
{
_collectionName = collectionName;
_databaseName = databaseName;
_maxBatchCount = maxBatchCount;
_maxBatchLength = maxBatchLength;
_maxDocumentSize = maxDocumentSize;
_maxWireDocumentSize = maxWireDocumentSize;
_isOrdered = isOrdered;
_readerSettings = readerSettings;
_requests = requests;
_writeConcern = writeConcern;
_writerSettings = writerSettings;
}
示例8: CreateOperation_should_return_expected_result
public void CreateOperation_should_return_expected_result(
[Values(false, true)]
bool isCommandSupported)
{
var requests = new[] { new CreateIndexRequest(new BsonDocument("x", 1)) };
var writeConcern = new WriteConcern(1);
var subject = new CreateIndexesOperation(_collectionNamespace, requests, _messageEncoderSettings)
{
WriteConcern = writeConcern
};
var serverVersion = Feature.CreateIndexesCommand.SupportedOrNotSupportedVersion(isCommandSupported);
var result = subject.CreateOperation(serverVersion);
if (isCommandSupported)
{
result.Should().BeOfType<CreateIndexesUsingCommandOperation>();
var operation = (CreateIndexesUsingCommandOperation)result;
operation.CollectionNamespace.Should().BeSameAs(_collectionNamespace);
operation.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings);
operation.Requests.Should().Equal(requests);
operation.WriteConcern.Should().BeSameAs(writeConcern);
}
else
{
result.Should().BeOfType<CreateIndexesUsingInsertOperation>();
var operation = (CreateIndexesUsingInsertOperation)result;
operation.CollectionNamespace.Should().BeSameAs(_collectionNamespace);
operation.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings);
operation.Requests.Should().Equal(requests);
}
}
示例9: BulkInsertOperationArgs
// constructors
public BulkInsertOperationArgs(
Action<InsertRequest> assignId,
bool checkElementNames,
string collectionName,
string databaseName,
int maxBatchCount,
int maxBatchLength,
int maxDocumentSize,
int maxWireDocumentSize,
bool isOrdered,
BsonBinaryReaderSettings readerSettings,
IEnumerable<InsertRequest> requests,
WriteConcern writeConcern,
BsonBinaryWriterSettings writerSettings)
: base(
collectionName,
databaseName,
maxBatchCount,
maxBatchLength,
maxDocumentSize,
maxWireDocumentSize,
isOrdered,
readerSettings,
requests.Cast<WriteRequest>(),
writeConcern,
writerSettings)
{
_assignId = assignId;
_checkElementNames = checkElementNames;
}
示例10: Impl
public Impl(MongoServer connection, WriteConcern writeConcern)
{
_writeConcern = writeConcern;
new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray().Take(4).ToArray(), 0)).NextBytes(_initialValue);
_collection =
connection.GetDatabase(typeof (SomeDocument).Name).GetCollection<SomeDocument>(typeof (SomeDocument).Name);
}
示例11: Constructor_with_string_argument_should_properly_initialize_instance
public void Constructor_with_string_argument_should_properly_initialize_instance()
{
var writeConcern = new WriteConcern("mode");
writeConcern.FSync.Should().NotHaveValue();
writeConcern.Journal.Should().NotHaveValue();
writeConcern.W.Should().Be((WriteConcern.WValue)"mode");
writeConcern.WTimeout.Should().NotHaveValue();
}
示例12: Constructor_with_no_arguments_should_properly_initialize_instance
public void Constructor_with_no_arguments_should_properly_initialize_instance()
{
var writeConcern = new WriteConcern();
writeConcern.FSync.Should().NotHaveValue();
writeConcern.Journal.Should().NotHaveValue();
writeConcern.W.Should().BeNull();
writeConcern.WTimeout.Should().NotHaveValue();
}
示例13: GridFSBucketOptions
/// <summary>
/// Initializes a new instance of the <see cref="GridFSBucketOptions"/> class.
/// </summary>
/// <param name="other">The other <see cref="ImmutableGridFSBucketOptions"/> from which to copy the values.</param>
public GridFSBucketOptions(ImmutableGridFSBucketOptions other)
{
Ensure.IsNotNull(other, nameof(other));
_bucketName = other.BucketName;
_chunkSizeBytes = other.ChunkSizeBytes;
_readConcern = other.ReadConcern;
_readPreference = other.ReadPreference;
_writeConcern = other.WriteConcern;
}
示例14: Save
public override WriteConcernResult Save(BsonDocument document, WriteConcern writeConcern, bool needResult)
{
// copy, make id, override
document = CloneExternalDocument(document);
var id = document.EnsureId();
bool updatedExisting = _data.ContainsKey(id);
_data[id] = document;
return needResult ? new WriteConcernResult(NewResponse(1, updatedExisting, null, null)) : null;
}
示例15: Constructor_with_four_arguments_should_properly_initialize_instance
public void Constructor_with_four_arguments_should_properly_initialize_instance(int? w, int? wTimeoutSeconds, bool? fsync, bool? journal)
{
var wCount = w.HasValue ? (WriteConcern.WValue)w.Value : null;
var wTimeout = wTimeoutSeconds.HasValue ? (TimeSpan?)TimeSpan.FromSeconds(wTimeoutSeconds.Value) : null;
var writeConcern = new WriteConcern(wCount, wTimeout, fsync, journal);
writeConcern.W.Should().Be(wCount);
writeConcern.WTimeout.Should().Be(wTimeout);
writeConcern.FSync.Should().Be(fsync);
writeConcern.Journal.Should().Be(journal);
}