本文整理汇总了C#中MongoDB.Driver.MongoConnectionStringBuilder.AddServer方法的典型用法代码示例。如果您正苦于以下问题:C# MongoConnectionStringBuilder.AddServer方法的具体用法?C# MongoConnectionStringBuilder.AddServer怎么用?C# MongoConnectionStringBuilder.AddServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Driver.MongoConnectionStringBuilder
的用法示例。
在下文中一共展示了MongoConnectionStringBuilder.AddServer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestToStringOutput
public void TestToStringOutput()
{
var builder = new MongoConnectionStringBuilder { Password = "testpassword", Username = "testusername", ConnectionLifetime = TimeSpan.FromSeconds (50), MaximumPoolSize = 101, MinimumPoolSize = 202, ConnectionTimeout = TimeSpan.FromSeconds(60)};
builder.AddServer ("testserver1", 555);
builder.AddServer ("testserver2");
Assert.AreEqual ("Username=testusername;Password=testpassword;Server=testserver1:555,testserver2;MaximumPoolSize=101;MinimumPoolSize=202;ConnectionTimeout=60;ConnectionLifetime=50", builder.ToString ());
}
示例2: CreateMongo
public static Mongo CreateMongo()
{
var builder = new MongoConnectionStringBuilder();
builder.AddServer(Host,Port);
return new Mongo(builder.ToString());
}
示例3: CreateConnection
public static Connection CreateConnection()
{
var builder = new MongoConnectionStringBuilder();
builder.AddServer(Host, Port);
return ConnectionFactory.GetConnection(builder.ToString());
}
示例4: TestToStringOutputWithoutUsernameAndPassword
public void TestToStringOutputWithoutUsernameAndPassword()
{
var builder = new MongoConnectionStringBuilder ();
builder.AddServer ("testserver", 555);
Assert.AreEqual ("Server=testserver:555", builder.ToString ());
}
示例5: TestToStringOutputWithDefaultServerPort
public void TestToStringOutputWithDefaultServerPort()
{
var builder = new MongoConnectionStringBuilder ();
builder.AddServer ("testserver");
Assert.AreEqual ("Server=testserver", builder.ToString ());
}
示例6: CreateConnectionStringBuilder
private static MongoConnectionStringBuilder CreateConnectionStringBuilder()
{
var builder = new MongoConnectionStringBuilder();
builder.AddServer("localhost", AuthServerPort);
return builder;
}