本文整理汇总了C#中BsonValue.ToBsonDocument方法的典型用法代码示例。如果您正苦于以下问题:C# BsonValue.ToBsonDocument方法的具体用法?C# BsonValue.ToBsonDocument怎么用?C# BsonValue.ToBsonDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonValue
的用法示例。
在下文中一共展示了BsonValue.ToBsonDocument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrySetArgument
protected override bool TrySetArgument(string name, BsonValue value)
{
switch (name)
{
case "filter":
_filter = (BsonDocument)value;
return true;
case "sort":
_options.Sort = value.ToBsonDocument();
return true;
case "limit":
_options.Limit = value.ToInt32();
return true;
case "skip":
_options.Skip = value.ToInt32();
return true;
case "batchSize":
_options.BatchSize = value.ToInt32();
return true;
case "modifiers":
_options.Modifiers = (BsonDocument)value;
return true;
}
return false;
}
示例2: GetBsonElementText
/// <summary>
/// 单个文档的TextView表示整理
/// </summary>
/// <param name="itemName"></param>
/// <param name="value"></param>
/// <param name="DeepLv"></param>
/// <returns></returns>
public static String GetBsonElementText(String itemName, BsonValue value, int DeepLv)
{
String rtnText = String.Empty;
if (value.IsBsonArray)
{
int count = 1;
BsonArray mBsonlst = value.AsBsonArray;
for (int BsonNo = 0; BsonNo < mBsonlst.Count; BsonNo++)
{
if (BsonNo == 0)
{
if (itemName != String.Empty)
{
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += " \"" + itemName + "\":";
}
rtnText += "[";
rtnText += "\r\n";
DeepLv++;
}
DeepLv++;
rtnText += GetBsonElementText(String.Empty, mBsonlst[BsonNo], DeepLv);
DeepLv--;
if (BsonNo == mBsonlst.Count - 1)
{
DeepLv--;
// "itemName": "Value"
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += " ]";
rtnText += "\r\n";
}
count++;
}
}
else
{
if (value.IsBsonDocument)
{
if (itemName != String.Empty)
{
// "itemName": "Value"
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += " \"" + itemName + "\":";
rtnText += "\r\n";
}
DeepLv++;
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += "{";
rtnText += "\r\n";
BsonDocument SubDoc = value.ToBsonDocument();
foreach (String SubitemName in SubDoc.Names)
{
BsonValue Subvalue = SubDoc.GetValue(SubitemName);
rtnText += GetBsonElementText(SubitemName, SubDoc.GetValue(SubitemName), DeepLv);
}
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += "}";
rtnText += "\r\n";
DeepLv--;
}
else
{
if (itemName != String.Empty)
{
// "itemName": "Value"
for (int i = 0; i < DeepLv; i++)
{
rtnText += " ";
}
rtnText += " \"" + itemName + "\":";
}
rtnText += ConvertForShow(value) + "\r\n";
}
}
return rtnText;
}
示例3: ConvertForShow
/// <summary>
/// BsonValue转展示用字符
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static string ConvertForShow(BsonValue val)
{
//二进制数据
if (val.IsBsonBinaryData)
{
_hasBSonBinary = true;
return "[二进制数据]";
}
//空值
if (val.IsBsonNull)
{
return "[空值]";
}
//文档
if (val.IsBsonDocument)
{
return val.ToString() + "[包含" + val.ToBsonDocument().ElementCount + "个元素的文档]";
}
//时间
if (val.IsBsonDateTime)
{
DateTime bsonData = val.AsDateTime;
//@flydreamer提出的本地化时间要求
return bsonData.ToLocalTime().ToString();
}
//字符
if (val.IsString)
{
//只有在字符的时候加上""
return "\"" + val.ToString() + "\"";
}
//其他
return val.ToString();
}
示例4: ConvertToString
/// <summary>
/// BsonValue转展示用字符
/// </summary>
/// <param name="bsonValue"></param>
/// <returns></returns>
public static String ConvertToString(BsonValue bsonValue)
{
//二进制数据
if (bsonValue.IsBsonBinaryData)
{
return "[Binary]";
}
//空值
if (bsonValue.IsBsonNull)
{
return "[Empty]";
}
//文档
if (bsonValue.IsBsonDocument)
{
return bsonValue.ToString() + "[Contains" + bsonValue.ToBsonDocument().ElementCount + "Documents]";
}
//时间
if (bsonValue.IsBsonDateTime)
{
DateTime bsonData = bsonValue.AsDateTime;
//@flydreamer提出的本地化时间要求
return bsonData.ToLocalTime().ToString();
}
//字符
if (bsonValue.IsString)
{
//只有在字符的时候加上""
return "\"" + bsonValue.ToString() + "\"";
}
//其他
return bsonValue.ToString();
}
示例5: ConvertForShow
/// <summary>
/// BsonValue转展示用字符
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static string ConvertForShow(BsonValue val)
{
string strVal;
if (val.IsBsonBinaryData)
{
_hasBSonBinary = true;
return "[二进制数据]";
}
if (val.IsBsonNull)
{
return "[空值]";
}
if (val.IsBsonDocument)
{
strVal = val.ToString() + "[包含" + val.ToBsonDocument().ElementCount + "个元素的文档]";
}
else
{
strVal = val.ToString();
}
return strVal;
}