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


C# Driver.MongoUrl類代碼示例

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


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

示例1: TestOneIPv6AddressWithPort

 public void TestOneIPv6AddressWithPort()
 {
     var connectionString = "mongodb://[::1:]:1234/?w=1";
     var url = new MongoUrl(connectionString);
     Assert.AreEqual("[::1:]", url.Server.Host);
     Assert.AreEqual(1234, url.Server.Port);
 }
開發者ID:bollinim,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:CSharp346Tests.cs

示例2: MongoRepository

 public MongoRepository(MongoUrl mongoUrl, string databaseName)
 {
     _client = new MongoClient(mongoUrl);
     _server = _client.GetServer();
     _database = databaseName;
     _server.Connect();
 }
開發者ID:WuLex,項目名稱:PerformanceCounterCollect,代碼行數:7,代碼來源:MongoRepository.cs

示例3: DropDatabaseTask

 public DropDatabaseTask(IAppConfig appConfig)
 {
     var url = new MongoUrl(appConfig.ProxyDbConnectionString);
     _mongoDatabase = new MongoClient(url)
         .GetServer()
         .GetDatabase(url.DatabaseName);
 }
開發者ID:ryanande,項目名稱:ApiProxy,代碼行數:7,代碼來源:DropDatabaseTask.cs

示例4: MongoGateway

 public MongoGateway(string mongoConnectionString)
 {
     var mongoUrl = new MongoUrl(mongoConnectionString);
     var client = new MongoClient(mongoConnectionString); 
     _dataBase = client.GetDatabase(mongoUrl.DatabaseName);
     CreateIndex();
 }
開發者ID:anktsrkr,項目名稱:MongoMembership,代碼行數:7,代碼來源:MongoGateway.cs

示例5: PurgeOrphanedBlobs

        private static void PurgeOrphanedBlobs(HashSet<String> blobsToDelete, String connectionString, String format)
        {
            Console.WriteLine("Found {0} orphaned blobs in BlobStorage named {1}", blobsToDelete.Count, format);
            if (blobsToDelete.Count > 0)
            {
                Console.WriteLine("Press y if you want to delete them, any other key to list without deletion");
                var key = Console.ReadKey();
                Console.WriteLine();
                if (Char.ToLower(key.KeyChar) == 'y')
                {
                    var uri = new MongoUrl(ConfigurationManager.AppSettings[connectionString]);
                    var client = new MongoClient(uri);

                    var database = client.GetServer().GetDatabase(uri.DatabaseName);
                    var settings = new MongoGridFSSettings()
                    {
                        Root = format
                    };
                    var gridfs = database.GetGridFS(settings);
                    foreach (var blobToDelete in blobsToDelete)
                    {
                        gridfs.DeleteById(blobToDelete);
                        Console.WriteLine("Deleted {0} in database {1}", blobToDelete, ConfigurationManager.AppSettings[connectionString]);
                    }
                }
                else
                {
                    foreach (var blobToDelete in blobsToDelete)
                    {
                        Console.WriteLine("Blob {0} in database {1} is orphaned", blobToDelete, ConfigurationManager.AppSettings[connectionString]);
                    }
                }
            }

        }
開發者ID:ProximoSrl,項目名稱:Jarvis.DocumentStore,代碼行數:35,代碼來源:CheckOrphanedBlobs.cs

示例6: SetUp

 public void SetUp()
 {
     var url = new MongoUrl(ConnectionString);
     var server = MongoServer.Create(url);
     var database = server.GetDatabase(url.DatabaseName);
     database.Drop();
 }
開發者ID:cdmckay,項目名稱:mongodb-aspnet-providers,代碼行數:7,代碼來源:TestProfileProvider.cs

示例7: GetDatabase

 public static MongoDatabase GetDatabase(string cstringName)
 {
     var cstring = ConfigurationManager.ConnectionStrings[cstringName].ConnectionString;
     var mongoUrl = new MongoUrl(cstring);
     var server = new MongoClient(mongoUrl).GetServer();
     return server.GetDatabase(mongoUrl.DatabaseName, new MongoDatabaseSettings());
 }
開發者ID:barissonmez,項目名稱:nes-training,代碼行數:7,代碼來源:MongoHelper.cs

示例8: Initialize

 public void Initialize(string connectionString)
 {
   var mongoUrl = new MongoUrl( connectionString );
   var client = new MongoClient( mongoUrl );
   _server = client.GetServer();
   _database = _server.GetDatabase( mongoUrl.DatabaseName );
 }
開發者ID:Epstone,項目名稱:CentralLog.Net,代碼行數:7,代碼來源:JobRepository.cs

示例9: ConfigureDatabase

 private static void ConfigureDatabase(string connection_string)
 {
     var url = new MongoUrl(connection_string);
     var client = new MongoClient(url);
     var server = client.GetServer();
     Configuration.Database = server.GetDatabase(url.DatabaseName);
 }
開發者ID:rashid-siddiqui,項目名稱:Reader,代碼行數:7,代碼來源:Configuration.cs

示例10: BaseController

 protected BaseController()
 {
     var url = new MongoUrl(ConnectionString());
     var client = new MongoClient(url);
     var server = client.GetServer();
     _mongoDatabase = server.GetDatabase(url.DatabaseName);
 }
開發者ID:pmprete,項目名稱:dondeducar,代碼行數:7,代碼來源:BaseController.cs

示例11: MongoDBSink

 /// <summary>
 /// Construct a sink posting to the specified database.
 /// </summary>
 /// <param name="databaseUrl">The URL of a CouchDB database.</param>
 /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
 /// <param name="period">The time to wait between checking for event batches.</param>
 /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
 public MongoDBSink(string databaseUrl, int batchPostingLimit, TimeSpan period, IFormatProvider formatProvider)
     : base(batchPostingLimit, period)
 {
     if (databaseUrl == null) throw new ArgumentNullException("databaseUrl");
     _formatProvider = formatProvider;
     _mongoUrl = new MongoUrl(databaseUrl);
 }
開發者ID:nicholaspei,項目名稱:serilog,代碼行數:14,代碼來源:MongoDBSink.cs

示例12: Install

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            var logUrl = new MongoUrl(_config.LogsConnectionString);
            var logDb = new MongoClient(logUrl).GetDatabase(logUrl.DatabaseName);
          
               
            container.Register(
                 Component
                    .For<IMessagesTracker>()
                    .ImplementedBy<MongoDbMessagesTracker>()
                    .DependsOn(Dependency.OnValue<IMongoDatabase>(logDb)),
                Component
                    .For<ICommandBus, IInProcessCommandBus>()
                    .ImplementedBy<DocumentStoreMultiTenantCommandBus>()
                );

            container.Register(
                Component
                    .For<IDocumentFormatTranslator>()
                    .ImplementedBy<StandardDocumentFormatTranslator>(),
                Component
                    .For<DocumentDescriptor>()
                    .LifestyleCustom(typeof(TransientNotTrackingLifestyle))
            );
        }
開發者ID:ProximoSrl,項目名稱:Jarvis.DocumentStore,代碼行數:25,代碼來源:CoreInstaller.cs

示例13: MongoStationRepository

 public MongoStationRepository(String connectionString)
 {
     var url = new MongoUrl(connectionString);
     var client = new MongoClient(connectionString);
     var server = client.GetServer();
     database = server.GetDatabase(url.DatabaseName);
 }
開發者ID:305088020,項目名稱:ChART,代碼行數:7,代碼來源:MongoStationRepository.cs

示例14: MongoLogger

        public MongoLogger() {
            var mongoUrl = new MongoUrl(ConfigurationManager.ConnectionStrings["LogDB"].ConnectionString);
            var client = new MongoClient(mongoUrl);
            var database = client.GetServer().GetDatabase(mongoUrl.DatabaseName);

            collection = database.GetCollection<MongoDBLogDo>("Log", WriteConcern.Unacknowledged);
        }
開發者ID:wudan330260402,項目名稱:Danwu.Core,代碼行數:7,代碼來源:MongoLogger.cs

示例15: FullTextSearch

        public FullTextSearch(string databaseName = "test", MongoUrl url = null)
        {
            mongoClient = url == null ? new MongoClient() : new MongoClient(url);
            database = mongoClient.GetDatabase(databaseName);

            database.CreateCollectionAsync("Students").Wait();
        }
開發者ID:maximburyak,項目名稱:TODA,代碼行數:7,代碼來源:FullTextSearch.cs


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