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


C# MongoConnectionStringBuilder.AddServer方法代碼示例

本文整理匯總了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 ());
        }
開發者ID:kvnsmth,項目名稱:mongodb-csharp,代碼行數:8,代碼來源:TestConnectionStringBuilder.cs

示例2: CreateMongo

 public static Mongo CreateMongo()
 {
     var builder = new MongoConnectionStringBuilder();
     builder.AddServer(Host,Port);
     return new Mongo(builder.ToString());
 }
開發者ID:deadtrickster,項目名稱:mongodb-csharp,代碼行數:6,代碼來源:AppSettingsFactory.cs

示例3: CreateConnection

 public static Connection CreateConnection()
 {
     var builder = new MongoConnectionStringBuilder();
     builder.AddServer(Host, Port);
     return ConnectionFactory.GetConnection(builder.ToString());
 }
開發者ID:deadtrickster,項目名稱:mongodb-csharp,代碼行數:6,代碼來源:AppSettingsFactory.cs

示例4: TestToStringOutputWithoutUsernameAndPassword

        public void TestToStringOutputWithoutUsernameAndPassword()
        {
            var builder = new MongoConnectionStringBuilder ();
            builder.AddServer ("testserver", 555);

            Assert.AreEqual ("Server=testserver:555", builder.ToString ());
        }
開發者ID:kvnsmth,項目名稱:mongodb-csharp,代碼行數:7,代碼來源:TestConnectionStringBuilder.cs

示例5: TestToStringOutputWithDefaultServerPort

 public void TestToStringOutputWithDefaultServerPort()
 {
     var builder = new MongoConnectionStringBuilder ();
     builder.AddServer ("testserver");
     Assert.AreEqual ("Server=testserver", builder.ToString ());
 }
開發者ID:kvnsmth,項目名稱:mongodb-csharp,代碼行數:6,代碼來源:TestConnectionStringBuilder.cs

示例6: CreateConnectionStringBuilder

 private static MongoConnectionStringBuilder CreateConnectionStringBuilder()
 {
     var builder = new MongoConnectionStringBuilder();
     builder.AddServer("localhost", AuthServerPort);
     return builder;
 }
開發者ID:deadtrickster,項目名稱:mongodb-csharp,代碼行數:6,代碼來源:TestAuthentication.cs


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