本文整理汇总了C#中Connection.ListDatabases方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ListDatabases方法的具体用法?C# Connection.ListDatabases怎么用?C# Connection.ListDatabases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.ListDatabases方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override Exchange Process(Exchange exchange, UriDescriptor endPointDescriptor)
{
try
{
Camel.TryLog(exchange, "provider", endPointDescriptor.ComponentName);
var dbHost = endPointDescriptor.ComponentPath;
var port = endPointDescriptor.GetUriProperty<int>("port");
var couchDbDatabase = exchange.InMessage.GetHeader("CouchDbDatabase");
var createDb = endPointDescriptor.GetUriProperty<bool>("createDb");
var document = exchange.InMessage.Body;
var dbUrl = string.Format("http://{0}:{1}", dbHost, port);
var conn = new Connection(new Uri(dbUrl));
if (createDb && !conn.ListDatabases().Contains(couchDbDatabase))
{
conn.CreateDatabase(couchDbDatabase.ToString());
}
}
catch (Exception exception)
{
}
return base.Process(exchange, endPointDescriptor);
}
示例2: Page_Load
protected void Page_Load( object sender, EventArgs e )
{
var url = ConfigurationManager.AppSettings.Get( "CLOUDANT_URL" );
var connection = new Connection( new Uri( url ) );
if ( !connection.ListDatabases().Contains( "gmkreports" ) )
{
connection.CreateDatabase( "gmkreports" );
}
var repository = new Repository<Report>( connection.CreateSession( "gmkreports" ) );
var report = new Report { ID = Guid.NewGuid(), Type = 1, AccessionNumber = "123", Contents = "abcd" };
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Reset();
watch.Start();
var id = repository.Save( report ).Id;
var retrievedReport = repository.Get( id );
watch.Stop();
if ( retrievedReport.ID == report.ID && retrievedReport.Type == report.Type && retrievedReport.AccessionNumber == report.AccessionNumber && retrievedReport.Contents == report.Contents )
{
_label.Text = watch.ElapsedMilliseconds.ToString();
}
else
{
_label.Text = "Error";
}
}
示例3: FixtureSetup
public void FixtureSetup()
{
_cx = ConnectionTests.CreateConnection();
if (_cx.ListDatabases().Contains("relax-query-tests"))
{
_cx.DeleteDatabase("relax-query-tests");
}
_cx.CreateDatabase("relax-query-tests");
_sx = _cx.CreateSession("relax-query-tests");
// populate a few widgets & a simple design doc
_sx.Save(new Widget { Name = "widget", Manufacturer = "acme" });
_sx.Save(new Widget { Name = "sprocket", Manufacturer = "acme" });
_sx.Save(new Widget { Name = "doodad", Manufacturer = "widgetco" });
_sx.Save(
new DesignDocument {
Language = "javascript",
Views = new Dictionary<string, View>
{
{ "all-widgets", new View {
Map = @"function(doc) { emit(null, null); }"
}},
{ "all-manufacturers", new View() {
Map = @"function(doc) { emit(doc.Manufacturer, 1); }",
Reduce = @"function(keys, values, rereduce) { return sum(values); }"
}}
}
},
"_design/widgets"
);
}
示例4: FixtureSetup
public void FixtureSetup()
{
_cx = ConnectionTests.CreateConnection();
if (_cx.ListDatabases().Contains("relax-reference-tests"))
{
_cx.DeleteDatabase("relax-reference-tests");
}
_cx.CreateDatabase("relax-reference-tests");
_sx = _cx.CreateSession("relax-reference-tests");
_sx2 = _cx.CreateSession("relax-reference-tests");
_sx.Save(new Widget { Id = "w1", Name = "Widget", Cost = 30 });
_sx.Save(new Widget { Id = "w2", Name = "Gadget", Cost = 30 });
_sx.Save(new Widget { Id = "w3", Name = "Foo", Cost = 35 });
_sx.Save(new Widget { Id = "w4", Name = "Bar", Cost = 35 });
_sx.Save(new Widget { Id = "w5", Name = "Biz", Cost = 45 });
_sx.Save(new Widget { Id = "w6", Name = "Bang", Cost = 55 });
_sx.SaveRaw(JObject.Parse(
@"{
_id: 'g1',
Name: 'Gadget #1',
Primary: 'w1'
}"));
_sx.SaveRaw(JObject.Parse(
@"{
_id: 'g2',
Name: 'Gadget #1',
Secondary: ['w1', 'w2', 'w3']
}"));
}
示例5: FixtureSetup
public void FixtureSetup()
{
_cx = ConnectionTests.CreateConnection();
if (_cx.ListDatabases().Contains("relax-observer-tests"))
{
_cx.DeleteDatabase("relax-observer-tests");
}
_cx.CreateDatabase("relax-observer-tests");
}
示例6: CouchRepositar
public CouchRepositar(string jmenoDatabaze)
{
_jmenoDatabaze = jmenoDatabaze;
var host = ConfigurationManager.AppSettings["CouchDB/Host"] ?? "localhost";
var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchDB/Port"] ?? "5984");
_store = new RedBranch.Hammock.Connection(new Uri(string.Format("http://{0}:{1}", host, port)));
if(!_store.ListDatabases().Contains(_jmenoDatabaze)) {
_store.CreateDatabase(_jmenoDatabaze);
}
}
示例7: CloudantDataService
public CloudantDataService()
{
var url = ConfigurationManager.AppSettings.Get( "CLOUDANT_URL" );
var connection = new Connection( new Uri( url ) );
if ( !connection.ListDatabases().Contains( "reports" ) )
{
connection.CreateDatabase( "reports" );
}
_repository = new Repository<Report>( connection.CreateSession( "reports" ) );
}
示例8: FixtureSetup
public void FixtureSetup()
{
_cx = ConnectionTests.CreateConnection();
if (_cx.ListDatabases().Contains("relax-session-tests"))
{
_cx.DeleteDatabase("relax-session-tests");
}
_cx.CreateDatabase("relax-session-tests");
_sx = _cx.CreateSession("relax-session-tests");
// create an initial document on a seperate session
var x = _cx.CreateSession(_sx.Database);
var w = new Widget {Name = "gizmo", Tags = new[] {"whizbang", "geegollie"}};
_doc = x.Save(w);
}