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

C# Driver.SafeMode类代码示例

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

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



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

示例1: MongoInsertOptions

 /// <summary>
 /// Initializes a new instance of the MongoInsertOptions class.
 /// </summary>
 /// <param name="collection">The collection from which to get default settings for the options.</param>
 public MongoInsertOptions(
     MongoCollection collection
 ) {
     this.checkElementNames = true;
     this.flags = InsertFlags.None;
     this.safeMode = collection.Settings.SafeMode;
 }
开发者ID:snedzad,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoInsertOptions.cs


示例2: MongoServerSettings

 public MongoServerSettings(
     ConnectionMode connectionMode,
     TimeSpan connectTimeout,
     MongoCredentials defaultCredentials,
     TimeSpan maxConnectionIdleTime,
     TimeSpan maxConnectionLifeTime,
     int maxConnectionPoolSize,
     int minConnectionPoolSize,
     string replicaSetName,
     SafeMode safeMode,
     IEnumerable<MongoServerAddress> servers,
     bool slaveOk,
     TimeSpan socketTimeout,
     int waitQueueSize,
     TimeSpan waitQueueTimeout
 )
 {
     this.connectionMode = connectionMode;
     this.connectTimeout = connectTimeout;
     this.defaultCredentials = defaultCredentials;
     this.maxConnectionIdleTime = maxConnectionIdleTime;
     this.maxConnectionLifeTime = maxConnectionLifeTime;
     this.maxConnectionPoolSize = maxConnectionPoolSize;
     this.minConnectionPoolSize = minConnectionPoolSize;
     this.replicaSetName = replicaSetName;
     this.safeMode = safeMode;
     this.servers = servers;
     this.slaveOk = slaveOk;
     this.socketTimeout = socketTimeout;
     this.waitQueueSize = waitQueueSize;
     this.waitQueueTimeout = waitQueueTimeout;
 }
开发者ID:Teun,项目名称:mongo-csharp-driver,代码行数:32,代码来源:MongoServerSettings.cs


示例3: MongoDatabaseSettings

 public MongoDatabaseSettings()
 {
     this.databaseName = null;
     this.credentials = null;
     this.safeMode = SafeMode.False;
     this.slaveOk = false;
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoDatabaseSettings.cs


示例4: MongoDatabaseSettings

        /// <summary>
        /// Creates a new instance of MongoDatabaseSettings.
        /// </summary>
        /// <param name="databaseName">The name of the database.</param>
        /// <param name="credentials">The credentials to access the database.</param>
        /// <param name="guidRepresentation">The representation for Guids.</param>
        /// <param name="readPreference">The read preference.</param>
        /// <param name="safeMode">The safe mode to use.</param>
        public MongoDatabaseSettings(
            string databaseName,
            MongoCredentials credentials,
            GuidRepresentation guidRepresentation,
            ReadPreference readPreference,
            SafeMode safeMode)
        {
            if (databaseName == null)
            {
                throw new ArgumentNullException("databaseName");
            }
            if (databaseName == "admin" && credentials != null && !credentials.Admin)
            {
                throw new ArgumentOutOfRangeException("Credentials for the admin database must have the admin flag set to true.");
            }
            if (readPreference == null)
            {
                throw new ArgumentNullException("readPreference");
            }
            if (safeMode == null)
            {
                throw new ArgumentNullException("safeMode");
            }

            _databaseName = databaseName;
            _credentials = credentials;
            _guidRepresentation = guidRepresentation;
            _readPreference = readPreference;
            _safeMode = safeMode;
        }
开发者ID:nickgervasi,项目名称:mongo-csharp-driver,代码行数:38,代码来源:MongoDatabaseSettings.cs


示例5: MongoDatabaseSettings

 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings.
 /// </summary>
 /// <param name="databaseName">The name of the database.</param>
 /// <param name="credentials">The credentials to access the database.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="safeMode">The safe mode to use.</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 public MongoDatabaseSettings(string databaseName, MongoCredentials credentials, GuidRepresentation guidRepresentation, SafeMode safeMode, bool slaveOk)
 {
     _databaseName = databaseName;
     _credentials = credentials;
     _guidRepresentation = guidRepresentation;
     _safeMode = safeMode;
     _slaveOk = slaveOk;
 }
开发者ID:moonreplace,项目名称:mongo-csharp-driver,代码行数:16,代码来源:MongoDatabaseSettings.cs


示例6: MongoDatabaseSettings

 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings.
 /// </summary>
 /// <param name="databaseName">The name of the database.</param>
 /// <param name="credentials">The credentials to access the database.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="safeMode">The safe mode to use.</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 public MongoDatabaseSettings(string databaseName, MongoCredentials credentials, GuidRepresentation guidRepresentation, SafeMode safeMode, ReadPreference readPreference)
 {
     this.databaseName = databaseName;
     this.credentials = credentials;
     this.guidRepresentation = guidRepresentation;
     this.safeMode = safeMode;
     this.readPreference = readPreference;
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:16,代码来源:MongoDatabaseSettings.cs


示例7: MongoCollectionSettings

 public MongoCollectionSettings()
 {
     this.collectionName = null;
     this.assignIdOnInsert = true;
     this.defaultDocumentType = typeof(BsonDocument);
     this.safeMode = SafeMode.False;
     this.slaveOk = false;
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:8,代码来源:MongoCollectionSettings.cs


示例8: MongoDatabaseSettings

 // constructors
 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings.
 /// </summary>
 /// <param name="server">The server to inherit settings from.</param>
 /// <param name="databaseName">The name of the database.</param>
 public MongoDatabaseSettings(MongoServer server, string databaseName)
 {
     var serverSettings = server.Settings;
     _databaseName = databaseName;
     _credentials = serverSettings.DefaultCredentials;
     _guidRepresentation = serverSettings.GuidRepresentation;
     _safeMode = serverSettings.SafeMode;
     _slaveOk = serverSettings.SlaveOk;
 }
开发者ID:purplecow,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoDatabaseSettings.cs


示例9: MongoCollectionSettings

 // constructors
 /// <summary>
 /// Initializes a new instance of the MongoCollectionSettings class.
 /// </summary>
 /// <param name="database">The database that contains the collection (some collection settings will be inherited from the database settings).</param>
 /// <param name="collectionName">The name of the collection.</param>
 /// <param name="defaultDocumentType">The default document type for the collection.</param>
 protected MongoCollectionSettings(MongoDatabase database, string collectionName, Type defaultDocumentType)
 {
     var databaseSettings = database.Settings;
     _collectionName = collectionName;
     _assignIdOnInsert = MongoDefaults.AssignIdOnInsert;
     _defaultDocumentType = defaultDocumentType;
     _guidRepresentation = databaseSettings.GuidRepresentation;
     _safeMode = databaseSettings.SafeMode;
     _slaveOk = databaseSettings.SlaveOk;
 }
开发者ID:abel,项目名称:sinan,代码行数:17,代码来源:MongoCollectionSettings.cs


示例10: TestCreateWithEnabledAndFSync

 public void TestCreateWithEnabledAndFSync()
 {
     var safeMode = new SafeMode(true, true);
     Assert.AreEqual(true, safeMode.Enabled);
     Assert.AreEqual(true, safeMode.FSync);
     Assert.AreEqual(false, safeMode.Journal);
     Assert.AreEqual(0, safeMode.W);
     Assert.AreEqual(null, safeMode.WMode);
     Assert.AreEqual(TimeSpan.Zero, safeMode.WTimeout);
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:10,代码来源:SafeModeTests.cs


示例11: TestCreateWithW

 public void TestCreateWithW()
 {
     var safeMode = new SafeMode(2);
     Assert.AreEqual(true, safeMode.Enabled);
     Assert.AreEqual(false, safeMode.FSync);
     Assert.AreEqual(false, safeMode.J);
     Assert.AreEqual(2, safeMode.W);
     Assert.AreEqual(null, safeMode.WMode);
     Assert.AreEqual(TimeSpan.Zero, safeMode.WTimeout);
 }
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:10,代码来源:SafeModeTests.cs


示例12: TestCreateWithEnabledAndFSyncAndWAndWTimeout

 public void TestCreateWithEnabledAndFSyncAndWAndWTimeout()
 {
     var safeMode = new SafeMode(true, true, 2, TimeSpan.FromSeconds(30));
     Assert.AreEqual(true, safeMode.Enabled);
     Assert.AreEqual(true, safeMode.FSync);
     Assert.AreEqual(false, safeMode.J);
     Assert.AreEqual(2, safeMode.W);
     Assert.AreEqual(null, safeMode.WMode);
     Assert.AreEqual(TimeSpan.FromSeconds(30), safeMode.WTimeout);
 }
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:10,代码来源:SafeModeTests.cs


示例13: MongoDatabaseSettings

 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings. Usually you would call MongoServer.CreateDatabaseSettings instead.
 /// </summary>
 /// <param name="databaseName">The name of the database.</param>
 /// <param name="credentials">The credentials to access the database.</param>
 /// <param name="safeMode">The safe mode to use.</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 public MongoDatabaseSettings(
     string databaseName,
     MongoCredentials credentials,
     SafeMode safeMode,
     bool slaveOk
 ) {
     this.databaseName = databaseName;
     this.credentials = credentials;
     this.safeMode = safeMode;
     this.slaveOk = slaveOk;
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:18,代码来源:MongoDatabaseSettings.cs


示例14: MongoDatabaseSettings

 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings. Usually you would call MongoServer.CreateDatabaseSettings instead.
 /// </summary>
 /// <param name="databaseName">The name of the database.</param>
 /// <param name="credentials">The credentials to access the database.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="safeMode">The safe mode to use.</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 public MongoDatabaseSettings(
     string databaseName,
     MongoCredentials credentials,
     GuidRepresentation guidRepresentation,
     SafeMode safeMode,
     bool slaveOk
 ) {
     this.databaseName = databaseName;
     this.credentials = credentials;
     this.guidRepresentation = guidRepresentation;
     this.safeMode = safeMode;
     this.slaveOk = slaveOk;
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:21,代码来源:MongoDatabaseSettings.cs


示例15: MongoCollectionSettings

 protected MongoCollectionSettings(
     string collectionName,
     bool assignIdOnInsert,
     Type defaultDocumentType,
     SafeMode safeMode,
     bool slaveOk
 ) {
     this.collectionName = collectionName;
     this.assignIdOnInsert = assignIdOnInsert;
     this.defaultDocumentType = defaultDocumentType;
     this.safeMode = safeMode;
     this.slaveOk = slaveOk;
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoCollectionSettings.cs


示例16: MongoUrl

 public MongoUrl(
     string url
 )
 {
     var builder = new MongoUrlBuilder(url);
     this.url = builder.ToString(); // keep canonical form
     this.credentials = builder.Credentials;
     this.servers = builder.Servers;
     this.databaseName = builder.DatabaseName;
     this.connectionMode = builder.ConnectionMode;
     this.replicaSetName = builder.ReplicaSetName;
     this.safeMode = builder.SafeMode ?? SafeMode.False; // never null
     this.slaveOk = builder.SlaveOk;
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:14,代码来源:MongoUrl.cs


示例17: MongoCollectionSettings

 /// <summary>
 /// Initializes a new instance of the MongoCollectionSettings class.
 /// </summary>
 /// <param name="collectionName">The name of the collection.</param>
 /// <param name="assignIdOnInsert">Whether to automatically assign a value to an empty document Id on insert.</param>
 /// <param name="defaultDocumentType">The default document type for the collection.</param>
 /// <param name="guidRepresentation">The GUID representation to use with this collection.</param>
 /// <param name="safeMode">The SafeMode to use with this collection.</param>
 /// <param name="slaveOk">Whether to route reads to secondaries for this collection.</param>
 protected MongoCollectionSettings(
     string collectionName,
     bool assignIdOnInsert,
     Type defaultDocumentType,
     GuidRepresentation guidRepresentation,
     SafeMode safeMode,
     bool slaveOk)
 {
     _collectionName = collectionName;
     _assignIdOnInsert = assignIdOnInsert;
     _defaultDocumentType = defaultDocumentType;
     _guidRepresentation = guidRepresentation;
     _safeMode = safeMode;
     _slaveOk = slaveOk;
 }
开发者ID:masukuma,项目名称:Nimbus,代码行数:24,代码来源:MongoCollectionSettings.cs


示例18: MongoServerSettings

 /// <summary>
 /// Creates a new instance of MongoServerSettings. Usually you would use a connection string instead.
 /// </summary>
 public MongoServerSettings() {
     connectionMode = ConnectionMode.Direct;
     connectTimeout = MongoDefaults.ConnectTimeout;
     defaultCredentials = null;
     ipv6 = false;
     maxConnectionIdleTime = MongoDefaults.MaxConnectionIdleTime;
     maxConnectionLifeTime = MongoDefaults.MaxConnectionLifeTime;
     maxConnectionPoolSize = MongoDefaults.MaxConnectionPoolSize;
     minConnectionPoolSize = MongoDefaults.MinConnectionPoolSize;
     replicaSetName = null;
     safeMode = MongoDefaults.SafeMode;
     servers = null;
     slaveOk = false;
     socketTimeout = MongoDefaults.SocketTimeout;
     waitQueueSize = MongoDefaults.ComputedWaitQueueSize;
     waitQueueTimeout = MongoDefaults.WaitQueueTimeout;
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:20,代码来源:MongoServerSettings.cs


示例19: MongoDatabaseSettings

 /// <summary>
 /// Creates a new instance of MongoDatabaseSettings.
 /// </summary>
 /// <param name="databaseName">The name of the database.</param>
 /// <param name="credentials">The credentials to access the database.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="safeMode">The safe mode to use.</param>
 /// <param name="slaveOk">Whether queries should be sent to secondary servers.</param>
 public MongoDatabaseSettings(
     string databaseName,
     MongoCredentials credentials,
     GuidRepresentation guidRepresentation,
     SafeMode safeMode,
     bool slaveOk)
 {
     if (databaseName == "admin" && credentials != null && !credentials.Admin)
     {
         throw new ArgumentOutOfRangeException("Credentials for the admin database must have the admin flag set to true.");
     }
     _databaseName = databaseName;
     _credentials = credentials;
     _guidRepresentation = guidRepresentation;
     _safeMode = safeMode;
     _slaveOk = slaveOk;
 }
开发者ID:abel,项目名称:sinan,代码行数:25,代码来源:MongoDatabaseSettings.cs


示例20: SetData

        public void SetData(string IdSession, string data, DateTime lastAccess)
        {
            MongoServer conn = GetConnection();
            MongoCollection sessionCollection = GetSessionCollection(conn);
            BsonDocument insertDoc = null;
            SafeMode _safeMode = new SafeMode(false);

            string sessItems = data;
            var ApplicationName = "IOL";
            Double timeout = this.GetTimeoutSet();
            object lockId = new object();

            try
            {
                if (!this.Exist(conn, IdSession, sessionCollection))
                {
                    insertDoc = new BsonDocument();
                    insertDoc.Add("_id", IdSession);
                    insertDoc.Add("ApplicationName", ApplicationName);
                    insertDoc.Add("Created", DateTime.Now.ToUniversalTime());
                    insertDoc.Add("Expires", DateTime.Now.AddMinutes((Double)timeout).ToUniversalTime());
                    insertDoc.Add("SessionItems", sessItems);

                    var query = Query.And(Query.EQ("_id", IdSession), Query.EQ("ApplicationName", ApplicationName), Query.LT("Expires", DateTime.Now.ToUniversalTime()));
                    sessionCollection.Remove(query, _safeMode);
                    sessionCollection.Insert(insertDoc, _safeMode);
                }
                else
                {
                    var query = Query.And(Query.EQ("_id", IdSession), Query.EQ("ApplicationName", ApplicationName));
                    var update = Update.Set("Expires", DateTime.Now.AddMinutes((Double)timeout).ToUniversalTime());
                    update.Set("SessionItems", sessItems);
                    sessionCollection.Update(query, update, _safeMode);
                }
            }
            catch (Exception e)
            {

            }
            finally
            {
                conn.Disconnect();
            }
        }
开发者ID:rrdiaz,项目名称:MongoDBSharedSession,代码行数:44,代码来源:MongoDataAccess.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Configuration.ClusterSettings类代码示例发布时间:2022-05-26
下一篇:
C# Driver.QueryDocument类代码示例发布时间: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