• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Driver.MongoDatabaseSettings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MongoDB.Driver.MongoDatabaseSettings的典型用法代码示例。如果您正苦于以下问题:C# MongoDatabaseSettings类的具体用法?C# MongoDatabaseSettings怎么用?C# MongoDatabaseSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MongoDatabaseSettings类属于MongoDB.Driver命名空间,在下文中一共展示了MongoDatabaseSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestConstructorArgumentChecking

 public void TestConstructorArgumentChecking()
 {
     var settings = new MongoDatabaseSettings(_server, "");
     Assert.Throws<ArgumentNullException>(() => { new MongoDatabase(null, settings); });
     Assert.Throws<ArgumentNullException>(() => { new MongoDatabase(_server, null); });
     Assert.Throws<ArgumentOutOfRangeException>(() => { new MongoDatabase(_server, settings); });
 }
开发者ID:nickgervasi,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoDatabaseTests.cs


示例2: TestEquals

        public void TestEquals()
        {
            var settings = new MongoDatabaseSettings();
            var clone = settings.Clone();
            Assert.IsTrue(clone.Equals(settings));

            settings.Freeze();
            clone.Freeze();
            Assert.IsTrue(clone.Equals(settings));

            clone = settings.Clone();
            clone.GuidRepresentation = GuidRepresentation.PythonLegacy;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadConcern = ReadConcern.Majority;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadPreference = ReadPreference.Secondary;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WriteConcern = WriteConcern.W2;
            Assert.IsFalse(clone.Equals(settings));
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:26,代码来源:MongoDatabaseSettingsTests.cs


示例3: TestAll

        public void TestAll() {
            var settings = new MongoDatabaseSettings(
                "database",
                MongoCredentials.Create("username", "password"),
                GuidRepresentation.CSharpLegacy,
                SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                true
            );

            Assert.AreEqual("database", settings.DatabaseName);
            Assert.AreEqual(MongoCredentials.Create("username", "password"), settings.Credentials);
            Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:25,代码来源:MongoDatabaseSettingsTests.cs


示例4: TestAll

        public void TestAll()
        {
            var server = MongoServer.Create();
            var settings = new MongoDatabaseSettings(server, "database")
            {
                Credentials = MongoCredentials.Create("username", "password"),
                SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                ReadPreference = ReadPreference.Primary
            };

            Assert.AreEqual("database", settings.DatabaseName);
            Assert.AreEqual(MongoCredentials.Create("username", "password"), settings.Credentials);
            Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(ReadPreference.Primary, settings.ReadPreference);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
开发者ID:nickgervasi,项目名称:mongo-csharp-driver,代码行数:26,代码来源:MongoDatabaseSettingsTests.cs


示例5: TestConstructor

 public void TestConstructor()
 {
     var settings = new MongoDatabaseSettings();
     Assert.AreEqual(GuidRepresentation.Unspecified, settings.GuidRepresentation);
     Assert.AreEqual(null, settings.ReadPreference);
     Assert.AreEqual(null, settings.WriteConcern);
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoDatabaseSettingsTests.cs


示例6: GetDatabase

 public static IMongoDatabase GetDatabase(string database, MongoDatabaseSettings dbSettings = null)
 {
     if(string.IsNullOrWhiteSpace(database))
         throw new ArgumentNullException("database");
     
     return Client.GetDatabase(database, dbSettings);
 }
开发者ID:pdlg-spotlight,项目名称:lambda-architecture,代码行数:7,代码来源:MongoDBManager.cs


示例7: TestEquals

        public void TestEquals()
        {
            var settings = new MongoDatabaseSettings();
            var clone = settings.Clone();
            Assert.IsTrue(clone.Equals(settings));

            settings.Freeze();
            clone.Freeze();
            Assert.IsTrue(clone.Equals(settings));

            clone = settings.Clone();
            clone.GuidRepresentation = GuidRepresentation.PythonLegacy;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.OperationTimeout = TimeSpan.FromMilliseconds(20);
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadPreference = ReadPreference.Secondary;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WriteConcern = WriteConcern.W2;
            Assert.IsFalse(clone.Equals(settings));
        }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:26,代码来源:MongoDatabaseSettingsTests.cs


示例8: TestEquals

        public void TestEquals()
        {
            var settings = new MongoDatabaseSettings();
            var clone = settings.Clone();
            Assert.IsTrue(clone.Equals(settings));

            settings.Freeze();
            clone.Freeze();
            Assert.IsTrue(clone.Equals(settings));

            clone = settings.Clone();
            clone.GuidRepresentation = GuidRepresentation.PythonLegacy;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadPreference = ReadPreference.Secondary;
            Assert.IsFalse(clone.Equals(settings));

#pragma warning disable 618
            clone = settings.Clone();
            clone.SafeMode = SafeMode.W2;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.SlaveOk = !settings.SlaveOk;
            Assert.IsFalse(clone.Equals(settings));
#pragma warning restore

            clone = settings.Clone();
            clone.WriteConcern = WriteConcern.W2;
            Assert.IsFalse(clone.Equals(settings));
        }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoDatabaseSettingsTests.cs


示例9: Register

        public static void Register(string databaseName, MongoDatabaseSettings settings = null)
        {
            if (_instance != null)
            {
                throw new Exception("Instance has been generated. Please call method DataStore.Instance for using");
            }

            _instance = new Lazy<DataStore>(() => new DataStore(databaseName, settings));
        }
开发者ID:mingezhao,项目名称:PersonalTools,代码行数:9,代码来源:DataStore.cs


示例10: UnitOfWork

 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork"/> class.
 /// </summary>
 public UnitOfWork()
 {
     const string dbName = "GuestBook";
     const string connectionString = "mongodb://localhost"; //TODO:USer App setting helper
     var client = new MongoClient(connectionString);
     var server = client.GetServer();
     var settings = new MongoDatabaseSettings();
     _database = server.GetDatabase(dbName, settings);//TODO:User app sertting helper
 }
开发者ID:NileshGokhale,项目名称:samplecode,代码行数:12,代码来源:UnitOfWork.cs


示例11: TestConstructor

        public void TestConstructor()
        {
            var settings = new MongoDatabaseSettings();
            Assert.AreEqual(GuidRepresentation.Unspecified, settings.GuidRepresentation);
            Assert.AreEqual(null, settings.ReadPreference);
#pragma warning disable 618
            Assert.AreEqual(null, settings.SafeMode);
#pragma warning restore
            Assert.AreEqual(null, settings.WriteConcern);
        }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MongoDatabaseSettingsTests.cs


示例12: TestFrozenCopy

 public void TestFrozenCopy()
 {
     var server = MongoServer.Create();
     var settings = new MongoDatabaseSettings(server, "database");
     var frozenCopy = settings.FrozenCopy();
     var secondFrozenCopy = frozenCopy.FrozenCopy();
     Assert.AreNotSame(settings, frozenCopy);
     Assert.AreSame(frozenCopy, secondFrozenCopy);
     Assert.AreEqual(false, settings.IsFrozen);
     Assert.AreEqual(true, frozenCopy.IsFrozen);
 }
开发者ID:nickgervasi,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoDatabaseSettingsTests.cs


示例13: GetMongoDatabase

 public static MongoDatabase GetMongoDatabase()
 {
     var url = GetUrl();
     var settings = new MongoDatabaseSettings
     {
         GuidRepresentation = GuidRepresentation.Standard,
         WriteConcern = WriteConcern.Acknowledged
     };
     var mongoDatabase = new MongoClient(url).GetServer().GetDatabase(url.DatabaseName, settings);
     return mongoDatabase;
 }
开发者ID:geffzhang,项目名称:Rebus,代码行数:11,代码来源:MongoTestHelper.cs


示例14: Setup

 public void Setup()
 {
     var settings = new MongoDatabaseSettings();
     settings.ApplyDefaultValues(new MongoClientSettings());
     _operationExecutor = new MockOperationExecutor();
     _subject = new MongoDatabaseImpl(
         new DatabaseNamespace("foo"),
         settings,
         Substitute.For<ICluster>(),
         _operationExecutor);
 }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoDatabaseImplTests.cs


示例15: GetDatabase

 public override MongoDatabase GetDatabase(string databaseName, MongoDatabaseSettings databaseSettings)
 {
     if (databaseName == null)
     {
         throw new ArgumentNullException("databaseName");
     }
     if (databaseSettings == null)
     {
         throw new ArgumentNullException("databaseSettings");
     }
     return new ProfiledMongoDatabase(this, databaseName, databaseSettings);
 }
开发者ID:CurufinweU,项目名称:dotnet,代码行数:12,代码来源:ProfiledMongoServer.cs


示例16: MongoDatabaseImplTests

 public MongoDatabaseImplTests()
 {
     var settings = new MongoDatabaseSettings();
     settings.ApplyDefaultValues(new MongoClientSettings());
     _operationExecutor = new MockOperationExecutor();
     _subject = new MongoDatabaseImpl(
         new Mock<IMongoClient>().Object,
         new DatabaseNamespace("foo"),
         settings,
         new Mock<ICluster>().Object,
         _operationExecutor);
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:12,代码来源:MongoDatabaseImplTests.cs


示例17: TestClone

 public void TestClone()
 {
     // set everything to non default values to test that all settings are cloned
     var settings = new MongoDatabaseSettings
     {
         GuidRepresentation = GuidRepresentation.PythonLegacy,
         ReadPreference = ReadPreference.Secondary,
         WriteConcern = WriteConcern.W2
     };
     var clone = settings.Clone();
     Assert.IsTrue(clone.Equals(settings));
 }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MongoDatabaseSettingsTests.cs


示例18: TestConstructor

        public void TestConstructor()
        {
            var settings = new MongoDatabaseSettings(_server, "database");
            Assert.AreEqual("database", settings.DatabaseName);
            Assert.AreEqual(null, settings.Credentials);
            Assert.AreEqual(MongoDefaults.GuidRepresentation, settings.GuidRepresentation);
            Assert.AreEqual(ReadPreference.Primary, settings.ReadPreference);
#pragma warning disable 618
            Assert.AreEqual(new SafeMode(false) { W = 1 }, settings.SafeMode);
            Assert.AreEqual(false, settings.SlaveOk);
#pragma warning restore
            Assert.AreEqual(WriteConcern.Acknowledged, settings.WriteConcern);
        }
开发者ID:gael-ltd,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoDatabaseSettingsTests.cs


示例19: Setup

 public void Setup()
 {
     var settings = new MongoCollectionSettings();
     var dbSettings = new MongoDatabaseSettings();
     dbSettings.ApplyDefaultValues(new MongoServerSettings());
     settings.ApplyDefaultValues(dbSettings);
     _operationExecutor = new MockOperationExecutor();
     _subject = new MongoCollectionImpl<BsonDocument>(
         new CollectionNamespace("foo", "bar"),
         settings,
         Substitute.For<ICluster>(),
         _operationExecutor);
 }
开发者ID:rmattos,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoCollectionImplTests.cs


示例20: TestClone

 public void TestClone()
 {
     // set everything to non default values to test that all settings are cloned
     var settings = new MongoDatabaseSettings(_server, "database")
     {
         Credentials = MongoCredentials.Create("username", "password"),
         GuidRepresentation = GuidRepresentation.PythonLegacy,
         ReadPreference = ReadPreference.Secondary,
         WriteConcern = WriteConcern.W2
     };
     var clone = settings.Clone();
     Assert.IsTrue(clone.Equals(settings));
 }
开发者ID:gael-ltd,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoDatabaseSettingsTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Driver.MongoInsertOptions类代码示例发布时间:2022-05-26
下一篇:
C# Driver.MongoDBRef类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap