當前位置: 首頁>>代碼示例>>C#>>正文


C# BsonValue.ToBoolean方法代碼示例

本文整理匯總了C#中BsonValue.ToBoolean方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonValue.ToBoolean方法的具體用法?C# BsonValue.ToBoolean怎麽用?C# BsonValue.ToBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BsonValue的用法示例。


在下文中一共展示了BsonValue.ToBoolean方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Compare

 public static bool Compare(BsonValue a, BsonValue b)
 {
     if (a.BsonType == BsonType.Document && b.BsonType == BsonType.Document)
     {
         return CompareDocuments((BsonDocument)a, (BsonDocument)b);
     }
     else if (a.BsonType == BsonType.Array && b.BsonType == BsonType.Array)
     {
         return CompareArrays((BsonArray)a, (BsonArray)b);
     }
     else if (a.BsonType == b.BsonType)
     {
         return a.Equals(b);
     }
     else if (IsNumber(a) && IsNumber(b))
     {
         return a.ToDouble() == b.ToDouble();
     }
     else if (CouldBeBoolean(a) && CouldBeBoolean(b))
     {
         return a.ToBoolean() == b.ToBoolean();
     }
     else
     {
         return false;
     }
 }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:27,代碼來源:BsonValueEquivalencyComparer.cs

示例2: TrySetArgument

        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
                case "documents":
                    _documents = ((BsonArray)value).OfType<BsonDocument>();
                    return true;
                case "ordered":
                    _options.IsOrdered = value.ToBoolean();
                    return true;
                case "writeConcern":
                    _writeConcern = WriteConcern.FromBsonDocument((BsonDocument)value);
                    return true;
            }

            return false;
        }
開發者ID:RainsSoft,項目名稱:mongo-csharp-driver,代碼行數:17,代碼來源:InsertManyTest.cs

示例3: TrySetArgument

        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
                case "requests":
                    _requests = ParseRequests((BsonArray)value).ToList();
                    return true;
                case "ordered":
                    _options.IsOrdered = value.ToBoolean();
                    return true;
                case "writeConcern":
                    _writeConcern = WriteConcern.FromBsonDocument((BsonDocument)value);
                    return true;
            }

            return false;
        }
開發者ID:RainsSoft,項目名稱:mongo-csharp-driver,代碼行數:17,代碼來源:BulkWriteTest.cs

示例4: TrySetArgument

        protected override bool TrySetArgument(string name, BsonValue value)
        {
            switch (name)
            {
                case "filter":
                    _filter = (BsonDocument)value;
                    return true;
                case "update":
                    _update = (BsonDocument)value;
                    return true;
                case "upsert":
                    _options.IsUpsert = value.ToBoolean();
                    return true;
                case "writeConcern":
                    _writeConcern = WriteConcern.FromBsonDocument((BsonDocument)value);
                    return true;
            }

            return false;
        }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:20,代碼來源:UpdateManyTest.cs

示例5: GetDataTypeValueFromBsonValue

        private object GetDataTypeValueFromBsonValue(BsonValue value, DataType dt)
        {
            if (dt == DataType.DT_I8 | dt == DataType.DT_I4)
            {
                if (value.IsString)
                {
                    Int64 parsedInt = -1;
                    if (!Int64.TryParse(value.ToString(), out parsedInt))
                    {
                        bool pbCancel = true;
                        ComponentMetaData.FireError(0, "MongoDataSource", "Cannot parse string value to integer: " + value.ToString(), "", 0, out pbCancel);
                    }
                    return parsedInt;
                }
                else
                {
                    return value.ToInt64();
                }
            }
            else if (dt == DataType.DT_BOOL)
            {
                return value.ToBoolean();
            }
            else if (dt == DataType.DT_R8 | dt == DataType.DT_R4)
            {
                return value.ToDouble();
            }
            else if (dt == DataType.DT_DATE | dt == DataType.DT_DBTIMESTAMPOFFSET | dt == DataType.DT_DBTIMESTAMP)
            {
                return DateTime.Parse(value.ToString());
            }
            else
            {
                if (dt != DataType.DT_STR && !value.IsObjectId && !value.IsString && !value.IsBsonSymbol)
                    ComponentMetaData.FireWarning(0, "MongoDataSource", "Converting " + value.BsonType + " to string, though datatype was " + dt, String.Empty, 0);

                return value.ToString();
            }
        }
開發者ID:samvau,項目名稱:mongosis,代碼行數:39,代碼來源:MongoDataSource.cs


注:本文中的BsonValue.ToBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。