本文整理汇总了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);
}
示例2: MongoRepository
public MongoRepository(MongoUrl mongoUrl, string databaseName)
{
_client = new MongoClient(mongoUrl);
_server = _client.GetServer();
_database = databaseName;
_server.Connect();
}
示例3: DropDatabaseTask
public DropDatabaseTask(IAppConfig appConfig)
{
var url = new MongoUrl(appConfig.ProxyDbConnectionString);
_mongoDatabase = new MongoClient(url)
.GetServer()
.GetDatabase(url.DatabaseName);
}
示例4: MongoGateway
public MongoGateway(string mongoConnectionString)
{
var mongoUrl = new MongoUrl(mongoConnectionString);
var client = new MongoClient(mongoConnectionString);
_dataBase = client.GetDatabase(mongoUrl.DatabaseName);
CreateIndex();
}
示例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]);
}
}
}
}
示例6: SetUp
public void SetUp()
{
var url = new MongoUrl(ConnectionString);
var server = MongoServer.Create(url);
var database = server.GetDatabase(url.DatabaseName);
database.Drop();
}
示例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());
}
示例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 );
}
示例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);
}
示例10: BaseController
protected BaseController()
{
var url = new MongoUrl(ConnectionString());
var client = new MongoClient(url);
var server = client.GetServer();
_mongoDatabase = server.GetDatabase(url.DatabaseName);
}
示例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);
}
示例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))
);
}
示例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);
}
示例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);
}
示例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();
}