当前位置: 首页>>代码示例>>C#>>正文


C# Connection.ListDatabases方法代码示例

本文整理汇总了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);
        }
开发者ID:ojoadeolagabriel,项目名称:TqWorkflow-beta,代码行数:26,代码来源:CouchDbProducer.cs

示例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";
     }
 }
开发者ID:saintarian,项目名称:AppHarborTest,代码行数:25,代码来源:Default.aspx.cs

示例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"
            );      
        }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:32,代码来源:QueryTests.cs

示例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']
            }"));

        }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:33,代码来源:ReferenceTests.cs

示例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");
 }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:9,代码来源:ObserverTests.cs

示例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);
     }
 }
开发者ID:rosic,项目名称:Soupiska,代码行数:10,代码来源:CouchRepositar.cs

示例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" ) );
 }
开发者ID:saintarian,项目名称:AppHarborTest,代码行数:10,代码来源:CloudantDataService.svc.cs

示例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);
        }
开发者ID:nicknystrom,项目名称:RedBranch.Hammock,代码行数:15,代码来源:SessionTests.cs


注:本文中的Connection.ListDatabases方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。