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


C# MongoUrlBuilder.ToString方法代碼示例

本文整理匯總了C#中MongoDB.Driver.MongoUrlBuilder.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# MongoUrlBuilder.ToString方法的具體用法?C# MongoUrlBuilder.ToString怎麽用?C# MongoUrlBuilder.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MongoDB.Driver.MongoUrlBuilder的用法示例。


在下文中一共展示了MongoUrlBuilder.ToString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MongoDBDatabase

        public MongoDBDatabase()
        {
            Name = "MongoDB";
            CollectionName = "collection";
            Category = "NoSQL\\Document Store";
            Description = "MongoDB C# Driver 2.0.0beta";
            Website = "http://www.mongodb.org/";
            Color = Color.FromArgb(235, 215, 151);

            Requirements = new string[]
            {
                "MongoDB.Bson.dll",
                "MongoDB.Driver.dll",
                "MongoDB.Driver.Core.dll",
                "MongoDB.Driver.Legacy.dll"
            };

            MongoUrlBuilder builder = new MongoUrlBuilder();
            builder.MaxConnectionIdleTime = TimeSpan.FromHours(1);
            builder.MaxConnectionLifeTime = TimeSpan.FromHours(1);
            builder.Server = new MongoServerAddress("localhost");
            builder.W = 1;

            ConnectionString = builder.ToString();
            InsertsPerQuery = 5000;
        }
開發者ID:pavel-gridnev,項目名稱:DatabaseBenchmark,代碼行數:26,代碼來源:MongoDBDatabase.cs

示例2: TestDefaults

        public void TestDefaults()
        {
            var builder = new MongoUrlBuilder();
            Assert.AreEqual(null, builder.DefaultCredentials);
            Assert.AreEqual(null, builder.Server);
            Assert.AreEqual(null, builder.Servers);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);
            Assert.AreEqual(MongoDefaults.ConnectTimeout, builder.ConnectTimeout);
            Assert.AreEqual(MongoDefaults.GuidRepresentation, builder.GuidRepresentation);
            Assert.AreEqual(false, builder.IPv6);
            Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, builder.MaxConnectionIdleTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, builder.MaxConnectionLifeTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, builder.MaxConnectionPoolSize);
            Assert.AreEqual(MongoDefaults.MinConnectionPoolSize, builder.MinConnectionPoolSize);
            Assert.AreEqual(null, builder.ReadPreference);
            Assert.AreEqual(null, builder.ReplicaSetName);
            Assert.AreEqual(null, builder.SafeMode);
#pragma warning disable 618
            Assert.AreEqual(false, builder.SlaveOk);
#pragma warning restore
            Assert.AreEqual(MongoDefaults.SocketTimeout, builder.SocketTimeout);
            Assert.AreEqual(MongoDefaults.WaitQueueMultiple, builder.WaitQueueMultiple);
            Assert.AreEqual(MongoDefaults.WaitQueueSize, builder.WaitQueueSize);
            Assert.AreEqual(MongoDefaults.WaitQueueTimeout, builder.WaitQueueTimeout);
            Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, builder.ComputedWaitQueueSize);

            var connectionString = "mongodb://"; // not actually a valid connection string because it's missing the host
            Assert.AreEqual(connectionString, builder.ToString());
        }
開發者ID:yfann,項目名稱:mongo-csharp-driver,代碼行數:30,代碼來源:MongoUrlBuilderTests.cs

示例3: TestConnectTimeout

        public void TestConnectTimeout()
        {
            var connectionString = "mongodb://localhost/?connectTimeout=123ms";
            var builder = new MongoUrlBuilder("mongodb://localhost") { ConnectTimeout = TimeSpan.FromMilliseconds(123) };
            Assert.AreEqual(TimeSpan.FromMilliseconds(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123s";
            builder = new MongoUrlBuilder("mongodb://localhost") { ConnectTimeout = TimeSpan.FromSeconds(123) };
            Assert.AreEqual(TimeSpan.FromSeconds(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123m";
            builder = new MongoUrlBuilder("mongodb://localhost") { ConnectTimeout = TimeSpan.FromMinutes(123) };
            Assert.AreEqual(TimeSpan.FromMinutes(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());

            connectionString = "mongodb://localhost/?connectTimeout=123h";
            builder = new MongoUrlBuilder("mongodb://localhost") { ConnectTimeout = TimeSpan.FromHours(123) };
            Assert.AreEqual(TimeSpan.FromHours(123), builder.ConnectTimeout);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:vshlos,項目名稱:mongo-csharp-driver,代碼行數:26,代碼來源:MongoUrlBuilderTests.cs

示例4: TestDefaults

        public void TestDefaults() {
            var builder = new MongoUrlBuilder();
            Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, builder.ComputedWaitQueueSize);
            Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
            Assert.AreEqual(MongoDefaults.ConnectTimeout, builder.ConnectTimeout);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(null, builder.DefaultCredentials);
            Assert.AreEqual(false, builder.IPv6);
            Assert.AreEqual(MongoDefaults.MaxConnectionIdleTime, builder.MaxConnectionIdleTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionLifeTime, builder.MaxConnectionLifeTime);
            Assert.AreEqual(MongoDefaults.MaxConnectionPoolSize, builder.MaxConnectionPoolSize);
            Assert.AreEqual(MongoDefaults.MinConnectionPoolSize, builder.MinConnectionPoolSize);
            Assert.AreEqual(null, builder.ReplicaSetName);
            Assert.AreEqual(null, builder.SafeMode);
            Assert.AreEqual(null, builder.Server);
            Assert.AreEqual(null, builder.Servers);
            Assert.AreEqual(false, builder.SlaveOk);
            Assert.AreEqual(MongoDefaults.SocketTimeout, builder.SocketTimeout);
            Assert.AreEqual(MongoDefaults.WaitQueueMultiple, builder.WaitQueueMultiple);
            Assert.AreEqual(MongoDefaults.WaitQueueSize, builder.WaitQueueSize);
            Assert.AreEqual(MongoDefaults.WaitQueueTimeout, builder.WaitQueueTimeout);

            var connectionString = "mongodb://";
            Assert.AreEqual(connectionString, builder.ToString());
        }
開發者ID:ebix,項目名稱:mongo-csharp-driver,代碼行數:25,代碼來源:MongoUrlBuilderTests.cs

示例5: TokuMXDatabase

        public TokuMXDatabase()
        {
            Name = "TokuMX";
            CollectionName = "collection";
            Category = "NoSQL\\Document Store";
            Description = "TokuMX v2.0";
            Website = "http://www.tokutek.com/tokumx-for-mongodb/";
            Color = Color.Chartreuse;

            Requirements = new string[]
            {
                "MongoDB.Bson.dll",
                "MongoDB.Driver.dll",
                "MongoDB.Driver.Core.dll",
                "MongoDB.Driver.Legacy.dll"
            };

            MongoUrlBuilder builder = new MongoUrlBuilder();
            builder.MaxConnectionIdleTime = TimeSpan.FromHours(1);
            builder.MaxConnectionLifeTime = TimeSpan.FromHours(1);
            builder.Server = new MongoServerAddress("localhost");
            builder.W = 1;

            ConnectionString = builder.ToString();
            InsertsPerQuery = 5000;
        }
開發者ID:pavel-gridnev,項目名稱:DatabaseBenchmark,代碼行數:26,代碼來源:TokuMXDatabase.cs

示例6: GetDatabaseConnectionString

        /// <summary>
        /// Gets the database connection string.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <returns></returns>
        internal static string GetDatabaseConnectionString(NameValueCollection config)
        {
            string connectionString = GetConnectionString(config);
            var builder = new MongoUrlBuilder(connectionString);
            builder.DatabaseName = GetDatabaseName(connectionString, config);

            return builder.ToString();
        }
開發者ID:saykorz,項目名稱:LunarBase,代碼行數:13,代碼來源:ConnectionHelper.cs

示例7: MangoDBSetDatabaseNameRandom

 private static string MangoDBSetDatabaseNameRandom(string connectionString)
 {
     var urlBuilder = new MongoUrlBuilder(connectionString)
                          {
                              DatabaseName = "brCounterTest_" + Guid.NewGuid().ToString("N")
                          };
     return urlBuilder.ToString();
 }
開發者ID:sFedyashov,項目名稱:BuildRevisionCounter,代碼行數:8,代碼來源:DBUtil.cs

示例8: MongoUrl

 /// <summary>
 /// Creates a new instance of MongoUrl.
 /// </summary>
 /// <param name="url">The URL containing the settings.</param>
 public MongoUrl(
     string url
 ) {
     var builder = new MongoUrlBuilder(url); // parses url
     serverSettings = builder.ToServerSettings().FrozenCopy();
     this.waitQueueMultiple = builder.WaitQueueMultiple;
     this.waitQueueSize = builder.WaitQueueSize;
     this.databaseName = builder.DatabaseName;
     this.url = builder.ToString(); // keep canonical form
 }
開發者ID:zxy050,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:MongoUrl.cs

示例9: TestHostWithPort

        public void TestHostWithPort() {
            var builder = new MongoUrlBuilder() { Server = new MongoServerAddress("mongo.xyz.com", 12345) };
            Assert.AreEqual(1, builder.Servers.Count());
            Assert.AreEqual("mongo.xyz.com", builder.Server.Host);
            Assert.AreEqual(12345, builder.Server.Port);
            Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
            Assert.AreEqual(null, builder.ReplicaSetName);

            var connectionString = "mongodb://mongo.xyz.com:12345";
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:ebix,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:MongoUrlBuilderTests.cs

示例10: TestHost

        public void TestHost()
        {
            var builder = new MongoUrlBuilder() { Server = new MongoServerAddress("mongo.xyz.com") };
            Assert.AreEqual(null, builder.DefaultCredentials);
            Assert.AreEqual(1, builder.Servers.Count());
            Assert.AreEqual("mongo.xyz.com", builder.Server.Host);
            Assert.AreEqual(27017, builder.Server.Port);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);

            var connectionString = "mongodb://mongo.xyz.com";
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:yfann,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:MongoUrlBuilderTests.cs

示例11: MongoUrl

 public MongoUrl(
     string url
 )
 {
     var builder = new MongoUrlBuilder(url);
     this.url = builder.ToString(); // keep canonical form
     this.credentials = builder.Credentials;
     this.servers = builder.Servers;
     this.databaseName = builder.DatabaseName;
     this.connectionMode = builder.ConnectionMode;
     this.replicaSetName = builder.ReplicaSetName;
     this.safeMode = builder.SafeMode ?? SafeMode.False; // never null
     this.slaveOk = builder.SlaveOk;
 }
開發者ID:kenegozi,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:MongoUrl.cs

示例12: TestConnectionMode

        public void TestConnectionMode()
        {
            var connectionString = "mongodb://localhost";
            var builder = new MongoUrlBuilder("mongodb://localhost") { ConnectionMode = ConnectionMode.Direct };
            Assert.AreEqual(ConnectionMode.Direct, builder.ConnectionMode);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());

            connectionString = "mongodb://localhost/?connect=replicaSet";
            builder = new MongoUrlBuilder("mongodb://localhost") { ConnectionMode = ConnectionMode.ReplicaSet };
            Assert.AreEqual(ConnectionMode.ReplicaSet, builder.ConnectionMode);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:vshlos,項目名稱:mongo-csharp-driver,代碼行數:14,代碼來源:MongoUrlBuilderTests.cs

示例13: BootstrapContainer

        private IContainer BootstrapContainer()
        {
            var container = new Container();
            container.Configure(cfg =>
            {
                cfg.Scan(scanner =>
                {
                    scanner.WithDefaultConventions();
                    scanner.AssemblyContainingType<IScript>();
                });

                var mongoUrlBuilder = new MongoUrlBuilder(Properties.Settings.Default.TestDatabaseConnectionString);

                cfg.For<MongoUrlBuilder>()
                    .Singleton()
                    .Use(new MongoUrlBuilder(Properties.Settings.Default.TestDatabaseConnectionString));

                cfg.For<MongoDatabase>()
                    .Transient()
                    .Use(ctx =>
                    {
                        var client = new MongoClient(mongoUrlBuilder.ToString());
                        client.GetServer().Connect();
                        return client.GetServer().GetDatabase(mongoUrlBuilder.DatabaseName);
                    });

                cfg.For<MongoDbScriptEnumerator>()
                    .Transient()
                    .Use<MongoDbScriptEnumerator>()
                    .Ctor<string>().Is(Properties.Settings.Default.LogCollectionName);

                cfg.For<MongoScriptRunner>()
                    .Transient()
                    .Use(() => new MongoScriptRunner(Properties.Settings.Default.MongoClientPath, mongoUrlBuilder.ToMongoUrl()));
            });

            return container;
        }
開發者ID:kahlin,項目名稱:mongomigrations,代碼行數:38,代碼來源:TestConventions.cs

示例14: TestTwoHosts

        public void TestTwoHosts()
        {
            var builder = new MongoUrlBuilder()
            {
                Servers = new MongoServerAddress[]
                { 
                    new MongoServerAddress("mongo1.xyz.com"),
                    new MongoServerAddress("mongo2.xyz.com") 
                }
            };
            var servers = builder.Servers.ToArray();
            Assert.AreEqual(null, builder.DefaultCredentials);
            Assert.AreEqual(2, servers.Length);
            Assert.AreEqual("mongo1.xyz.com", servers[0].Host);
            Assert.AreEqual(27017, servers[0].Port);
            Assert.AreEqual("mongo2.xyz.com", servers[1].Host);
            Assert.AreEqual(27017, servers[1].Port);
            Assert.AreEqual(null, builder.DatabaseName);
            Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);
            Assert.AreEqual(null, builder.ReplicaSetName);

            var connectionString = "mongodb://mongo1.xyz.com,mongo2.xyz.com";
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:yfann,項目名稱:mongo-csharp-driver,代碼行數:25,代碼來源:MongoUrlBuilderTests.cs

示例15: TestSlaveOkTrue

        public void TestSlaveOkTrue()
        {
#pragma warning disable 618
            var builder = new MongoUrlBuilder("mongodb://localhost") { SlaveOk = true };
            Assert.AreEqual(true, builder.SlaveOk);
#pragma warning restore

            var connectionString = "mongodb://localhost/?slaveOk=true";
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new MongoUrlBuilder(connectionString).ToString());
        }
開發者ID:yfann,項目名稱:mongo-csharp-driver,代碼行數:11,代碼來源:MongoUrlBuilderTests.cs


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