本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}