當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。