本文整理汇总了C#中BsonValue.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# BsonValue.ToString方法的具体用法?C# BsonValue.ToString怎么用?C# BsonValue.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonValue
的用法示例。
在下文中一共展示了BsonValue.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BsonValueEx
/// <summary>
/// 初始化
/// </summary>
/// <param name="value"></param>
public BsonValueEx(BsonValue value)
{
if (value.IsString)
{
MBsonType = "BsonString";
MBsonString = value.ToString();
}
if (value.IsInt32)
{
MBsonType = "BsonInt32";
MBsonInt32 = value.AsInt32;
}
if (value.IsValidDateTime)
{
MBsonType = "BsonDateTime";
MBsonDateTime = value.ToUniversalTime();
}
if (value.IsBoolean)
{
MBsonType = "BsonBoolean";
MBsonBoolean = value.AsBoolean;
}
if (value.IsDouble)
{
MBsonType = "BsonDouble";
MBsonDouble = value.AsDouble;
}
}
示例2: GetValue
public string GetValue(BsonValue value)
{
if (value.IsBsonNull)
return "null";
else
return value.ToString();
}
示例3: OplogNamespace
public OplogNamespace(BsonValue bsonValue)
{
if(bsonValue == null)
{
throw new MongoRiverException("Namespace not defined on document.");
}
BuildParts(bsonValue.ToString());
}
示例4: BsonValueEx
/// <summary>
/// 初始化
/// </summary>
/// <param name="value"></param>
public BsonValueEx(BsonValue value)
{
if (value.IsString)
{
mBsonType = BasicType.BsonString;
mBsonString = value.ToString();
}
if (value.IsInt32)
{
mBsonType = BasicType.BsonInt32;
mBsonInt32 = value.AsInt32;
}
if (value.IsInt64)
{
mBsonType = BasicType.BsonInt64;
mBsonInt64 = value.AsInt64;
}
if (value.IsDecimal128)
{
mBsonType = BasicType.BsonDecimal128;
mBSonDecimal128 = value.AsDecimal;
}
if (value.IsDouble)
{
mBsonType = BasicType.BsonDouble;
mBsonDouble = value.AsDouble;
}
if (value.IsValidDateTime)
{
mBsonType = BasicType.BsonDateTime;
mBsonDateTime = value.ToUniversalTime();
}
if (value.IsBoolean)
{
mBsonType = BasicType.BsonBoolean;
mBsonBoolean = value.AsBoolean;
}
if (value.IsBsonMaxKey)
{
mBsonType = BasicType.BsonMaxKey;
}
if (value.IsBsonMinKey)
{
mBsonType = BasicType.BsonMinKey;
}
if (value.IsBsonBinaryData)
{
mBsonType = BasicType.BsonBinary;
mBsonBinary = value.AsBsonBinaryData.Bytes;
}
}
示例5: BsonValueEx
/// <summary>
/// 初始化
/// </summary>
/// <param name="value"></param>
public BsonValueEx(BsonValue value)
{
if (value.IsString)
{
mBsonType = "BsonString";
mBsonString = value.ToString();
}
if (value.IsInt32)
{
mBsonType = "BsonInt32";
mBsonInt32 = value.AsInt32;
}
if (value.IsDateTime)
{
mBsonType = "BsonDateTime";
mBsonDateTime = value.AsDateTime;
}
if (value.IsBoolean)
{
mBsonType = "BsonBoolean";
mBsonBoolean = value.AsBoolean;
}
}
示例6: 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();
}
示例7: AddTagRange
/// <summary>
/// AddTagRange
/// </summary>
/// <param name="routeSvr">路由服务器</param>
/// <param name="nameSpace">名字空间</param>
/// <param name="min">最小值</param>
/// <param name="max">最大值</param>
/// <param name="tag">标签</param>
/// <returns></returns>
public static CommandResult AddTagRange(MongoServer routeSvr, string nameSpace, BsonValue min, BsonValue max,
string tag)
{
//mongos> sh.addTagRange
//function (ns, min, max, tag) {
// var config = db.getSisterDB("config");
// config.tags.update(
// {_id:{ns:ns, min:min}},
// {
// _id:{ns:ns, min:min},
// ns:ns,
// min:min,
// max:max,
// tag:tag
// },
// true
// );
// sh._checkLastError(config);
//}
var maxValue = string.Empty;
var minValue = string.Empty;
if (min.IsString)
{
minValue = "'" + min + "'";
}
if (max.IsString)
{
maxValue = "'" + max + "'";
}
if (min.IsNumeric)
{
minValue = min.ToString();
}
if (max.IsNumeric)
{
maxValue = max.ToString();
}
return ExecuteJsShell(
"sh.addTagRange('" + nameSpace + "'," + minValue + "," + maxValue + ",'" + tag + "')", routeSvr);
}
示例8: 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();
}
示例9: setValue
/// <summary>
/// 使用属性会发生一些MONO上的移植问题
/// </summary>
/// <returns></returns>
public void setValue(BsonValue value)
{
txtBsonValue.Visible = false;
txtBsonValue.Text = String.Empty;
txtBsonValue.ReadOnly = false;
radTrue.Visible = false;
radFalse.Visible = false;
radFalse.Checked = true;
dateTimePicker.Visible = false;
NumberPick.Visible = false;
if (value.IsString)
{
cmbDataType.SelectedIndex = 0;
txtBsonValue.Visible = true;
txtBsonValue.Text = value.ToString();
}
if (value.IsInt32)
{
cmbDataType.SelectedIndex = 1;
NumberPick.Visible = true;
NumberPick.Value = value.AsInt32;
}
if (value.IsValidDateTime)
{
dateTimePicker.Visible = true;
dateTimePicker.Value = value.ToUniversalTime();
cmbDataType.SelectedIndex = 2;
}
if (value.IsBoolean)
{
radTrue.Visible = true;
radFalse.Visible = true;
if (value.AsBoolean)
{
radTrue.Checked = true;
}
else
{
radFalse.Checked = true;
}
cmbDataType.SelectedIndex = 3;
}
if (value.IsBsonArray)
{
frmArrayCreator frmInsertArray = new frmArrayCreator();
SystemManager.OpenForm(frmInsertArray, false, true);
if (frmInsertArray.mBsonArray != null)
{
mBsonArray = frmInsertArray.mBsonArray;
txtBsonValue.Visible = true;
txtBsonValue.Text = mBsonArray.ToString();
txtBsonValue.ReadOnly = true;
cmbDataType.SelectedIndex = 4;
}
}
if (value.IsBsonDocument)
{
frmNewDocument frmInsertDoc = new frmNewDocument();
SystemManager.OpenForm(frmInsertDoc, false, true);
if (frmInsertDoc.mBsonDocument != null)
{
mBsonDocument = frmInsertDoc.mBsonDocument;
txtBsonValue.Visible = true;
txtBsonValue.Text = mBsonDocument.ToString();
txtBsonValue.ReadOnly = true;
cmbDataType.SelectedIndex = 5;
}
}
}
示例10: SetValue
/// <summary>
/// 使用属性会发生一些MONO上的移植问题
/// </summary>
/// <returns></returns>
public void SetValue(BsonValue value)
{
txtBsonValue.Visible = false;
txtBsonValue.Text = string.Empty;
txtBsonValue.ReadOnly = false;
radTrue.Visible = false;
radFalse.Visible = false;
radFalse.Checked = true;
dateTimePicker.Visible = false;
NumberPick.Visible = false;
if (value.IsString)
{
cmbDataType.SelectedIndex = 0;
txtBsonValue.Visible = true;
txtBsonValue.Text = value.ToString();
}
if (value.IsInt32)
{
cmbDataType.SelectedIndex = 1;
NumberPick.Visible = true;
NumberPick.Value = value.AsInt32;
}
if (value.IsValidDateTime)
{
dateTimePicker.Visible = true;
dateTimePicker.Value = value.ToUniversalTime();
cmbDataType.SelectedIndex = 2;
}
if (value.IsBoolean)
{
radTrue.Visible = true;
radFalse.Visible = true;
if (value.AsBoolean)
{
radTrue.Checked = true;
}
else
{
radFalse.Checked = true;
}
cmbDataType.SelectedIndex = 3;
}
if (value.IsBsonArray)
{
var t = GetArray();
if (t != null)
{
_mBsonArray = t;
txtBsonValue.Visible = true;
txtBsonValue.Text = _mBsonArray.ToString();
txtBsonValue.ReadOnly = true;
cmbDataType.SelectedIndex = 4;
}
}
if (value.IsBsonDocument)
{
var t = GetDocument();
if (t != null)
{
_mBsonDocument = t;
txtBsonValue.Visible = true;
txtBsonValue.Text = _mBsonDocument.ToString();
txtBsonValue.ReadOnly = true;
cmbDataType.SelectedIndex = 5;
}
}
}
示例11: RunCommand
public static string RunCommand(string conn, string command)
{
//List<BsonDocument> results = new List<BsonDocument>();
BsonValue bv = new BsonValue();
string retval_bvv = string.Empty; // bv.ToString();
try
{
using (var db = new LiteDatabase(conn))
{
Console.WriteLine( bv.ToString());
//BsonValue bv = db.RunCommand("db.customer.insert { Name: \"John Doe\" }");
//BsonValue bv = db.RunCommand("db.fuck.find glossary.GlossDiv.GlossList.GlossEntry.ID like \"SGML\"");
//BsonValue bv = db.RunCommand(@"db.fuck.bulk C:\FxM\Dev\vs12\LiteDB\LiteDB-master\LiteDB.Shell\bin\Debug\test.dmp");
//BsonValue bv = db.RunCommand(@"db.fuck.bulk ..\..\..\..\test.dmp");
bv = db.RunCommand(command);
//JObject json22 = bv.// JObject.Parse(bv.ToString);
retval_bvv = bv.ToString();
//var json = LiteDB.JsonSerializer.Serialize(bv);
//Console.WriteLine(json.ToString());
}
}
catch (Exception ex)
{
Console.WriteLine("wtf: " + ex.Message);
retval_bvv = ex.Message;
}
return retval_bvv;
}
示例12: AddTagRange
/// <summary>
/// AddTagRange
/// </summary>
/// <param name="routeSvr">路由服务器</param>
/// <param name="NameSpace">名字空间</param>
/// <param name="Min">最小值</param>
/// <param name="Max">最大值</param>
/// <param name="Tag">标签</param>
/// <returns></returns>
public static CommandResult AddTagRange(MongoServer routeSvr, String NameSpace, BsonValue Min, BsonValue Max, String Tag)
{
//mongos> sh.addTagRange
//function (ns, min, max, tag) {
// var config = db.getSisterDB("config");
// config.tags.update(
// {_id:{ns:ns, min:min}},
// {
// _id:{ns:ns, min:min},
// ns:ns,
// min:min,
// max:max,
// tag:tag
// },
// true
// );
// sh._checkLastError(config);
//}
CommandDocument mongoCmd = new CommandDocument();
String MaxValue = String.Empty;
String MinValue = String.Empty;
if (Min.IsString)
{
MinValue = "'" + Min.ToString() + "'";
}
if (Max.IsString)
{
MaxValue = "'" + Max.ToString() + "'";
}
if (Min.IsNumeric)
{
MinValue = Min.ToString();
}
if (Max.IsNumeric)
{
MaxValue = Max.ToString();
}
return ExecuteJsShell("sh.addTagRange('" + NameSpace + "'," + MinValue + "," + MaxValue + ",'" + Tag + "')", routeSvr);
}
示例13: ConvertRawValue
private static object ConvertRawValue(BsonValue bsonValue)
{
if (bsonValue == null)
return null;
if (BsonTypeMapper.MapToDotNetValue(bsonValue) != null)
{
if (bsonValue.IsObjectId)
{
return bsonValue.ToString();
}
else if (bsonValue.IsGuid)
{
return bsonValue.AsGuid;
}
else
{
switch (bsonValue.BsonType)
{
case BsonType.DateTime:
return UnixEpoch + TimeSpan.FromMilliseconds(bsonValue.AsBsonDateTime.MillisecondsSinceEpoch);
default:
return BsonTypeMapper.MapToDotNetValue(bsonValue);
}
}
}
else
{
switch (bsonValue.BsonType)
{
case BsonType.Binary:
return bsonValue.AsBsonBinaryData.Bytes;
default:
return BsonTypeMapper.MapToDotNetValue(bsonValue);
}
}
}
示例14: ValueToString
private string ValueToString(BsonValue value)
{
if (value == BsonNull.Value)
{
return null;
}
return value.ToString();
}
示例15: ConvertData
private string ConvertData(BsonValue val)
{
string str = val.ToString();
if (val.IsValidDateTime) str = (val as BsonDateTime).ToLocalTime().ToString();
else if (val.IsBsonNull) str = string.Empty;
return str;
}