本文整理汇总了C#中MongoDB.Driver.MongoServerSettings.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# MongoServerSettings.Freeze方法的具体用法?C# MongoServerSettings.Freeze怎么用?C# MongoServerSettings.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.MongoServerSettings
的用法示例。
在下文中一共展示了MongoServerSettings.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MongoUrl
public MongoUrl(
string url
)
{
var builder = new MongoUrlBuilder(url); // parses url
serverSettings = builder.ToServerSettings();
serverSettings.Freeze();
this.waitQueueMultiple = builder.WaitQueueMultiple;
this.waitQueueSize = builder.WaitQueueSize;
this.databaseName = builder.DatabaseName;
this.url = builder.ToString(); // keep canonical form
}
示例2: TestConnectionMode
public void TestConnectionMode()
{
var settings = new MongoServerSettings();
Assert.AreEqual(ConnectionMode.Automatic, settings.ConnectionMode);
var connectionMode = ConnectionMode.Direct;
settings.ConnectionMode = connectionMode;
Assert.AreEqual(connectionMode, settings.ConnectionMode);
settings.Freeze();
Assert.AreEqual(connectionMode, settings.ConnectionMode);
Assert.Throws<InvalidOperationException>(() => { settings.ConnectionMode = connectionMode; });
}
示例3: TestConnectTimeout
public void TestConnectTimeout()
{
var settings = new MongoServerSettings();
Assert.AreEqual(MongoDefaults.ConnectTimeout, settings.ConnectTimeout);
var connectTimeout = new TimeSpan(1, 2, 3);
settings.ConnectTimeout = connectTimeout;
Assert.AreEqual(connectTimeout, settings.ConnectTimeout);
settings.Freeze();
Assert.AreEqual(connectTimeout, settings.ConnectTimeout);
Assert.Throws<InvalidOperationException>(() => { settings.ConnectTimeout = connectTimeout; });
}
示例4: TestApplicationName
public void TestApplicationName()
{
var settings = new MongoServerSettings();
Assert.Equal(null, settings.ApplicationName);
var applicationName = "app2";
settings.ApplicationName = applicationName;
Assert.Equal(applicationName, settings.ApplicationName);
settings.Freeze();
Assert.Equal(applicationName, settings.ApplicationName);
Assert.Throws<InvalidOperationException>(() => { settings.ApplicationName = applicationName; });
}
示例5: TestAll
public void TestAll()
{
var settings = new MongoServerSettings();
settings.ConnectionMode = ConnectionMode.ReplicaSet;
settings.ConnectTimeout = TimeSpan.FromSeconds(1);
settings.DefaultCredentials = MongoCredentials.Create("username", "password");
settings.GuidRepresentation = GuidRepresentation.CSharpLegacy;
settings.IPv6 = true;
settings.MaxConnectionIdleTime = TimeSpan.FromSeconds(2);
settings.MaxConnectionLifeTime = TimeSpan.FromSeconds(3);
settings.MaxConnectionPoolSize = 99;
settings.MinConnectionPoolSize = 11;
settings.ReadPreference = ReadPreference.Primary;
settings.ReplicaSetName = "replicaname";
settings.SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(4));
settings.Server = new MongoServerAddress("server");
settings.SocketTimeout = TimeSpan.FromSeconds(5);
settings.UseSsl = true;
settings.WaitQueueSize = 55;
settings.WaitQueueTimeout = TimeSpan.FromSeconds(6);
Assert.AreEqual(ConnectionMode.ReplicaSet, settings.ConnectionMode);
Assert.AreEqual(TimeSpan.FromSeconds(1), settings.ConnectTimeout);
Assert.AreEqual(MongoCredentials.Create("username", "password"), settings.DefaultCredentials);
Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
Assert.AreEqual(true, settings.IPv6);
Assert.AreEqual(TimeSpan.FromSeconds(2), settings.MaxConnectionIdleTime);
Assert.AreEqual(TimeSpan.FromSeconds(3), settings.MaxConnectionLifeTime);
Assert.AreEqual(99, settings.MaxConnectionPoolSize);
Assert.AreEqual(11, settings.MinConnectionPoolSize);
Assert.AreEqual(ReadPreference.Primary, settings.ReadPreference);
Assert.AreEqual("replicaname", settings.ReplicaSetName);
Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(4)), settings.SafeMode);
Assert.AreEqual(new MongoServerAddress("server"), settings.Server);
Assert.IsTrue((new[] { new MongoServerAddress("server") }).SequenceEqual(settings.Servers));
Assert.AreEqual(TimeSpan.FromSeconds(5), settings.SocketTimeout);
Assert.AreEqual(true, settings.UseSsl);
Assert.AreEqual(55, settings.WaitQueueSize);
Assert.AreEqual(TimeSpan.FromSeconds(6), settings.WaitQueueTimeout);
Assert.IsFalse(settings.IsFrozen);
var hashCode = settings.GetHashCode();
var stringRepresentation = settings.ToString();
Assert.AreEqual(settings, settings);
settings.Freeze();
Assert.IsTrue(settings.IsFrozen);
Assert.AreEqual(hashCode, settings.GetHashCode());
Assert.AreEqual(stringRepresentation, settings.ToString());
}
示例6: TestHeartbeatTimeout
public void TestHeartbeatTimeout()
{
var settings = new MongoServerSettings();
Assert.Equal(ServerSettings.DefaultHeartbeatTimeout, settings.HeartbeatTimeout);
var heartbeatTimeout = new TimeSpan(1, 2, 3);
settings.HeartbeatTimeout = heartbeatTimeout;
Assert.Equal(heartbeatTimeout, settings.HeartbeatTimeout);
settings.Freeze();
Assert.Equal(heartbeatTimeout, settings.HeartbeatTimeout);
Assert.Throws<InvalidOperationException>(() => { settings.HeartbeatTimeout = heartbeatTimeout; });
}
示例7: TestVerifySslCertificate
public void TestVerifySslCertificate()
{
var settings = new MongoServerSettings();
Assert.AreEqual(true, settings.VerifySslCertificate);
var verifySslCertificate = false;
settings.VerifySslCertificate = verifySslCertificate;
Assert.AreEqual(verifySslCertificate, settings.VerifySslCertificate);
settings.Freeze();
Assert.AreEqual(verifySslCertificate, settings.VerifySslCertificate);
Assert.Throws<InvalidOperationException>(() => { settings.VerifySslCertificate = verifySslCertificate; });
}
示例8: TestSslSettings
public void TestSslSettings()
{
var settings = new MongoServerSettings();
Assert.AreEqual(null, settings.SslSettings);
var sslSettings = new SslSettings { CheckCertificateRevocation = false };
settings.SslSettings = sslSettings;
Assert.AreEqual(sslSettings, settings.SslSettings);
settings.Freeze();
Assert.AreEqual(sslSettings, settings.SslSettings);
Assert.Throws<InvalidOperationException>(() => { settings.SslSettings = sslSettings; });
}
示例9: TestSecondaryAcceptableLatency
public void TestSecondaryAcceptableLatency()
{
var settings = new MongoServerSettings();
Assert.AreEqual(MongoDefaults.SecondaryAcceptableLatency, settings.SecondaryAcceptableLatency);
var secondaryAcceptableLatency = new TimeSpan(1, 2, 3);
settings.SecondaryAcceptableLatency = secondaryAcceptableLatency;
Assert.AreEqual(secondaryAcceptableLatency, settings.SecondaryAcceptableLatency);
settings.Freeze();
Assert.AreEqual(secondaryAcceptableLatency, settings.SecondaryAcceptableLatency);
Assert.Throws<InvalidOperationException>(() => { settings.SecondaryAcceptableLatency = secondaryAcceptableLatency; });
}
示例10: TestReadPreference
public void TestReadPreference()
{
var settings = new MongoServerSettings();
Assert.AreEqual(ReadPreference.Primary, settings.ReadPreference);
var readPreference = new ReadPreference();
settings.ReadPreference = readPreference;
Assert.AreSame(readPreference, settings.ReadPreference);
Assert.IsFalse(settings.ReadPreference.IsFrozen);
settings.Freeze();
Assert.AreEqual(readPreference, settings.ReadPreference);
Assert.IsTrue(settings.ReadPreference.IsFrozen);
Assert.Throws<InvalidOperationException>(() => { settings.ReadPreference = readPreference; });
}
示例11: TestDefaultCredentials
public void TestDefaultCredentials()
{
var settings = new MongoServerSettings();
Assert.AreEqual(null, settings.DefaultCredentials);
var defaultCredentials = new MongoCredentials("user1", "password1");
settings.DefaultCredentials = defaultCredentials;
Assert.AreSame(defaultCredentials, settings.DefaultCredentials);
settings.Freeze();
Assert.AreSame(defaultCredentials, settings.DefaultCredentials);
Assert.Throws<InvalidOperationException>(() => { settings.DefaultCredentials = defaultCredentials; });
}
示例12: TestWaitQueueTimeout
public void TestWaitQueueTimeout()
{
var settings = new MongoServerSettings();
Assert.Equal(MongoDefaults.WaitQueueTimeout, settings.WaitQueueTimeout);
var waitQueueTimeout = new TimeSpan(1, 2, 3);
settings.WaitQueueTimeout = waitQueueTimeout;
Assert.Equal(waitQueueTimeout, settings.WaitQueueTimeout);
settings.Freeze();
Assert.Equal(waitQueueTimeout, settings.WaitQueueTimeout);
Assert.Throws<InvalidOperationException>(() => { settings.WaitQueueTimeout = waitQueueTimeout; });
}
示例13: TestServersWithOneServer
public void TestServersWithOneServer()
{
var settings = new MongoServerSettings();
Assert.Equal(_localHost, settings.Server);
Assert.True(new[] { _localHost }.SequenceEqual(settings.Servers));
var server = new MongoServerAddress("server");
var servers = new[] { server };
settings.Servers = servers;
Assert.Equal(server, settings.Server);
Assert.True(servers.SequenceEqual(settings.Servers));
settings.Freeze();
Assert.Equal(server, settings.Server);
Assert.True(servers.SequenceEqual(settings.Servers));
Assert.Throws<InvalidOperationException>(() => { settings.Server = server; });
}
示例14: TestReadPreference
public void TestReadPreference()
{
var settings = new MongoServerSettings();
Assert.Equal(ReadPreference.Primary, settings.ReadPreference);
var readPreference = ReadPreference.Primary;
settings.ReadPreference = readPreference;
Assert.Same(readPreference, settings.ReadPreference);
settings.Freeze();
Assert.Equal(readPreference, settings.ReadPreference);
Assert.Throws<InvalidOperationException>(() => { settings.ReadPreference = readPreference; });
}
示例15: TestMaxConnectionLifeTime
public void TestMaxConnectionLifeTime()
{
var settings = new MongoServerSettings();
Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, settings.MaxConnectionLifeTime);
var maxConnectionLifeTime = new TimeSpan(1, 2, 3);
settings.MaxConnectionLifeTime = maxConnectionLifeTime;
Assert.AreEqual(maxConnectionLifeTime, settings.MaxConnectionLifeTime);
settings.Freeze();
Assert.AreEqual(maxConnectionLifeTime, settings.MaxConnectionLifeTime);
Assert.Throws<InvalidOperationException>(() => { settings.MaxConnectionLifeTime = maxConnectionLifeTime; });
}