本文整理匯總了C#中MongoDB.Driver.Core.Configuration.ClusterSettings.With方法的典型用法代碼示例。如果您正苦於以下問題:C# ClusterSettings.With方法的具體用法?C# ClusterSettings.With怎麽用?C# ClusterSettings.With使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Driver.Core.Configuration.ClusterSettings
的用法示例。
在下文中一共展示了ClusterSettings.With方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ConfigureCluster
private ClusterSettings ConfigureCluster(ClusterSettings settings, ClusterKey clusterKey)
{
var endPoints = clusterKey.Servers.Select(s => EndPointHelper.Parse(s.ToString()));
return settings.With(
connectionMode: clusterKey.ConnectionMode.ToCore(),
endPoints: Optional.Enumerable(endPoints),
replicaSetName: clusterKey.ReplicaSetName,
maxServerSelectionWaitQueueSize: clusterKey.WaitQueueSize,
serverSelectionTimeout: clusterKey.ServerSelectionTimeout,
postServerSelector: new LatencyLimitingServerSelector(clusterKey.LocalThreshold));
}
示例2: CreateSubject
private StubCluster CreateSubject(ClusterConnectionMode connectionMode = ClusterConnectionMode.Automatic, TimeSpan? serverSelectionTimeout = null)
{
_settings = _settings.With(connectionMode: connectionMode);
if (serverSelectionTimeout != null)
{
_settings = _settings.With(serverSelectionTimeout: serverSelectionTimeout.Value);
}
return new StubCluster(_settings, _mockServerFactory.Object, _capturedEvents);
}
示例3: With_replicaSetName_should_return_expected_result
public void With_replicaSetName_should_return_expected_result()
{
var oldReplicaSetName = "abc";
var newReplicaSetName = "def";
var subject = new ClusterSettings(replicaSetName: oldReplicaSetName);
var result = subject.With(replicaSetName: newReplicaSetName);
result.ConnectionMode.Should().Be(subject.ConnectionMode);
result.EndPoints.Should().EqualUsing(subject.EndPoints, EndPointHelper.EndPointEqualityComparer);
result.MaxServerSelectionWaitQueueSize.Should().Be(subject.MaxServerSelectionWaitQueueSize);
result.ReplicaSetName.Should().Be(newReplicaSetName);
result.ServerSelectionTimeout.Should().Be(subject.ServerSelectionTimeout);
}
示例4: With_serverSelectionTimeout_should_return_expected_result
public void With_serverSelectionTimeout_should_return_expected_result()
{
var oldServerSelectionTimeout = TimeSpan.FromSeconds(1);
var newServerSelectionTimeout = TimeSpan.FromSeconds(2);
var subject = new ClusterSettings(serverSelectionTimeout: oldServerSelectionTimeout);
var result = subject.With(serverSelectionTimeout: newServerSelectionTimeout);
result.ConnectionMode.Should().Be(subject.ConnectionMode);
result.EndPoints.Should().EqualUsing(subject.EndPoints, EndPointHelper.EndPointEqualityComparer);
result.MaxServerSelectionWaitQueueSize.Should().Be(subject.MaxServerSelectionWaitQueueSize);
result.ReplicaSetName.Should().Be(subject.ReplicaSetName);
result.ServerSelectionTimeout.Should().Be(newServerSelectionTimeout);
}
示例5: With_endPoints_should_return_expected_result
public void With_endPoints_should_return_expected_result()
{
var oldEndPoints = new[] { new DnsEndPoint("remotehost1", 27123) };
var newEndPoints = new[] { new DnsEndPoint("remotehost2", 27123) };
var subject = new ClusterSettings(endPoints: oldEndPoints);
var result = subject.With(endPoints: newEndPoints);
result.ConnectionMode.Should().Be(subject.ConnectionMode);
result.EndPoints.Should().EqualUsing(newEndPoints, EndPointHelper.EndPointEqualityComparer);
result.MaxServerSelectionWaitQueueSize.Should().Be(subject.MaxServerSelectionWaitQueueSize);
result.ReplicaSetName.Should().Be(subject.ReplicaSetName);
result.ServerSelectionTimeout.Should().Be(subject.ServerSelectionTimeout);
}