當前位置: 首頁>>代碼示例>>C#>>正文


C# ClusterSettings.With方法代碼示例

本文整理匯總了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));
 }
開發者ID:mfidemraizer,項目名稱:mongo-csharp-driver,代碼行數:11,代碼來源:ClusterRegistry.cs

示例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);
        }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:10,代碼來源:ClusterTests.cs

示例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);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:ClusterSettingsTests.cs

示例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);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:ClusterSettingsTests.cs

示例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);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:ClusterSettingsTests.cs


注:本文中的MongoDB.Driver.Core.Configuration.ClusterSettings.With方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。