本文整理匯總了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;
}