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