本文整理汇总了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);
}