当前位置: 首页>>代码示例>>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;未经允许,请勿转载。