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


C# BsonDocument.Contains方法代码示例

本文整理汇总了C#中BsonDocument.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.Contains方法的具体用法?C# BsonDocument.Contains怎么用?C# BsonDocument.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BsonDocument的用法示例。


在下文中一共展示了BsonDocument.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneralTrigger

        public GeneralTrigger(BsonDocument doc, TriggerType triggerType) {
            TriggerOn = new List<string>();
            And = new List<string>();
            NotOn = new List<string>();
            MessageOverrideAsString = new List<string>();
            if (doc != null && doc.ElementCount > 0 && doc.Contains("TriggerOn")) {
                foreach (var on in doc["TriggerOn"].AsBsonArray) {
                    TriggerOn.Add(on.AsString);
                }
                foreach (var and in doc["And"].AsBsonArray) {
                    And.Add(and.AsString);
                }
                foreach (var not in doc["NoTriggerOn"].AsBsonArray) {
                    NotOn.Add(not.AsString);
                }
                AutoProcess = doc.Contains("AutoProcess") ? doc["AutoProcess"].AsBoolean : false;
                ChanceToTrigger = doc["ChanceToTrigger"].AsInt32;
                script = ScriptFactory.GetScript(doc["ScriptID"].AsString, triggerType.ToString());
                foreach (var overrides in doc["Overrides"].AsBsonArray) {
                    MessageOverrideAsString.Add(overrides.AsString);
                }
                Type = doc["Type"].AsString;
				TriggerId = doc["Id"].AsString;
            }
        }
开发者ID:jandar78,项目名称:Novus,代码行数:25,代码来源:Trigger.cs

示例2: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            decimal price = 0m;
            if (!document.Contains(OrganizationRepository.FieldNames.PlanId))
                return;

            switch (document.GetValue(OrganizationRepository.FieldNames.PlanId).AsString) {
                case "EX_SMALL":
                    price = BillingManager.SmallPlan.Price;
                    break;
                case "EX_MEDIUM":
                    price = BillingManager.MediumPlan.Price;
                    break;
                case "EX_LARGE":
                    price = BillingManager.LargePlan.Price;
                    break;
            }

            if (price == 0m)
                return;

            if (!document.Contains(OrganizationRepository.FieldNames.BillingPrice))
                document.Add(OrganizationRepository.FieldNames.BillingPrice, new BsonString(price.ToString()));
            else
                document.Set(OrganizationRepository.FieldNames.BillingPrice, new BsonString(price.ToString()));

            collection.Save(document);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:27,代码来源:v1.0.23.cs

示例3: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
        {
            if (document.Contains("ErrorCount"))
                document.ChangeName("ErrorCount", "EventCount");

            if (document.Contains("TotalErrorCount"))
                document.ChangeName("TotalErrorCount", "TotalEventCount");

            if (document.Contains("LastErrorDate"))
                document.ChangeName("LastErrorDate", "LastEventDate");

            if (document.Contains("MaxErrorsPerMonth"))
                document.ChangeName("MaxErrorsPerMonth", "MaxEventsPerMonth");

            if (document.Contains("SuspensionCode")) {
                var value = document.GetValue("SuspensionCode");
                document.Remove("SuspensionCode");

                SuspensionCode suspensionCode;
                if (value.IsString && Enum.TryParse(value.AsString, true, out suspensionCode))
                    document.Set("SuspensionCode", suspensionCode);
            }

            collection.Save(document);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:25,代码来源:v1.0.32.cs

示例4: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("OverageHours"))
                document.Remove("OverageHours");

            if (document.Contains("Usage"))
                document.Remove("Usage");

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:9,代码来源:v1.0.30.cs

示例5: InsertOneBsonDocument

 public void InsertOneBsonDocument()
 {
     var bsonDocument = new BsonDocument()
     {
         {"Name","Mehmet Çakır"},
         {"Email","[email protected]"}
     };
     bsonDocument.Contains("_id").Should().BeFalse();
     Func<Task> act = () => BlogContext.UserAsBson.InsertOneAsync(bsonDocument);
     act.ShouldNotThrow();
     bsonDocument.Contains("_id").Should().BeTrue();
     bsonDocument["_id"].Should().NotBe(ObjectId.Empty);
 }
开发者ID:emretiryaki,项目名称:NetMongoDbQueryTest,代码行数:13,代码来源:InsertTests.cs

示例6: GetUpdateFlags

        /// <summary>
        /// 
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        private UpdateFlags GetUpdateFlags(BsonDocument document) {
            var flags = UpdateFlags.None;

            if (document.Contains("upsert")) {
                flags = flags | ((document["upsert"].ToBoolean()) ? (UpdateFlags.Upsert) : (UpdateFlags.None));
            }

            if (document.Contains("multi")) {
                flags = flags | ((document["multi"].ToBoolean()) ? (UpdateFlags.Upsert) : (UpdateFlags.None));
            }

            return flags;
        }
开发者ID:Qorpent,项目名称:qorpent.integration,代码行数:18,代码来源:DirectQuery.cs

示例7: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("OverageDays"))
                document.Remove("OverageDays");

            if (document.Contains("MaxErrorsPerDay")) {
                document.ChangeName("MaxErrorsPerDay", "MaxErrorsPerMonth");
                var maxErrorsPerMonth = document.GetValue("MaxErrorsPerMonth").AsInt32;
                if (maxErrorsPerMonth > 0)
                    document.Set("MaxErrorsPerMonth", maxErrorsPerMonth * 30);
            }

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:13,代码来源:v1.0.29.cs

示例8: AggregateResult

 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="AggregateResult" /> class.
 /// </summary>
 /// <param name="response">The response.</param>
 public AggregateResult(BsonDocument response)
     : base(response)
 {
     if (response.Contains("cursor"))
     {
         var cursorDocument = response["cursor"];
         _cursorId = cursorDocument["id"].ToInt64();
         _resultDocuments = cursorDocument["firstBatch"].AsBsonArray.Select(v => v.AsBsonDocument);
     }
     if (response.Contains("result"))
     {
         _resultDocuments = response["result"].AsBsonArray.Select(v => v.AsBsonDocument);
     }
 }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:19,代码来源:AggregateResult.cs

示例9: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("OrganizationId"))
                document.ChangeName("OrganizationId", "oid");
            
            if (document.Contains("ProjectId"))
                document.ChangeName("ProjectId", "pid");

            if (document.Contains("Version"))
                document.Remove("Version");

            document.Set("Version", "1.0.0.0");

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:14,代码来源:v1.0.36.cs

示例10: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (!document.Contains(OrganizationRepository.FieldNames.PlanId))
                return;

            string planId = document.GetValue(OrganizationRepository.FieldNames.PlanId).AsString;
            if (String.IsNullOrEmpty(planId) || !String.Equals(planId, BillingManager.FreePlan.Id))
                return;

            if (!document.Contains(OrganizationRepository.FieldNames.RetentionDays))
                document.Add(OrganizationRepository.FieldNames.RetentionDays, new BsonInt64(BillingManager.FreePlan.RetentionDays));
            else
                document.Set(OrganizationRepository.FieldNames.RetentionDays, new BsonInt64(BillingManager.FreePlan.RetentionDays));

            collection.Save(document);
        }
开发者ID:GuilhermeMorais,项目名称:Exceptionless,代码行数:15,代码来源:v1.0.25.cs

示例11: And

        /// <summary>
        /// Combines subqueries with an and operator.
        /// </summary>
        /// <param name="queries">The subqueries.</param>
        /// <returns>The builder (so method calls can be chained).</returns>
        public static QueryComplete And(
            params QueryComplete[] queries
        ) {
            var document = new BsonDocument();
            foreach (var query in queries) {
                foreach (var queryElement in query.ToBsonDocument()) {
                    // if result document has existing operations for same field append the new ones
                    if (document.Contains(queryElement.Name)) {
                        var existingOperations = document[queryElement.Name] as BsonDocument;
                        var newOperations = queryElement.Value as BsonDocument;

                        // make sure that no conditions are Query.EQ, because duplicates aren't allowed
                        if (existingOperations == null || newOperations == null) {
                            var message = string.Format("Query.And does not support combining equality comparisons with other operators (field: '{0}')", queryElement.Name);
                            throw new InvalidOperationException(message);
                        }

                        // add each new operation to the existing operations
                        foreach (var operation in newOperations) {
                            // make sure that there are no duplicate $operators
                            if (existingOperations.Contains(operation.Name)) {
                                var message = string.Format("Query.And does not support using the same operator more than once (field: '{0}', operator: '{1}')", queryElement.Name, operation.Name);
                                throw new InvalidOperationException(message);
                            } else {
                                existingOperations.Add(operation);
                            }
                        }
                    } else {
                        document.Add(queryElement);
                    }
                }
            }
            return new QueryComplete(document);
        }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:39,代码来源:QueryBuilder.cs

示例12: GetMatchDocument

 /// <summary>
 /// 获取Match
 /// </summary>
 /// <returns></returns>
 public BsonDocument GetMatchDocument()
 {
     BsonDocument Matchlist = new BsonDocument();
     foreach (ctlMatchItem item in this.Controls)
     {
         BsonDocument match = item.getMatchItem();
         if (match != null)
         {
             string MatchName = match.GetElement(0).Name;
             if (Matchlist.Contains(MatchName))
             {
                 BsonDocument AddMatch = match.GetElement(0).Value.AsBsonDocument;
                 Matchlist.GetElement(MatchName).Value.AsBsonDocument.Add(AddMatch);
             }
             else {
                 Matchlist.Add(match);
             }
         }
     }
     if (Matchlist.ElementCount > 0)
     {
         return new BsonDocument("$match", Matchlist);
     }
     else
     {
         return null;
     }
 }
开发者ID:Eddie0330,项目名称:MagicMongoDBTool,代码行数:32,代码来源:MatchPanel.cs

示例13: GetMatchDocument

 /// <summary>
 ///     获取Match
 /// </summary>
 /// <returns></returns>
 public BsonDocument GetMatchDocument()
 {
     var matchlist = new BsonDocument();
     foreach (Control item in Controls)
     {
         if (item.GetType().FullName == typeof(Button).FullName) continue;
         var match = ((CtlMatchItem)item).GetMatchItem();
         if (match != null)
         {
             var matchName = match.GetElement(0).Name;
             if (matchlist.Contains(matchName))
             {
                 var addMatch = match.GetElement(0).Value.AsBsonDocument;
                 matchlist.GetElement(matchName).Value.AsBsonDocument.AddRange(addMatch);
             }
             else
             {
                 matchlist.AddRange(match);
             }
         }
     }
     if (matchlist.ElementCount > 0)
     {
         return new BsonDocument("$match", matchlist);
     }
     return null;
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:31,代码来源:ctlMatchPanel.cs

示例14: GetDateTime

 public static DateTime GetDateTime(BsonDocument doc, string propertyName)
 {
     DateTime result = DateTime.MinValue;
     if (doc.Contains(propertyName))
         result = doc[propertyName].ToUniversalTime();
     return result;
 }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:7,代码来源:BsonHelper.cs

示例15: GetArray

 public static BsonArray GetArray(BsonDocument doc, string propertyName)
 {
     BsonArray result = null;
     if (doc.Contains(propertyName))
         result = doc[propertyName].AsBsonArray;
     return result;
 }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:7,代码来源:BsonHelper.cs


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