当前位置: 首页>>代码示例>>C#>>正文


C# BsonValue.ToString方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:1287516153,项目名称:MongoCola,代码行数:32,代码来源:BsonValueEx.cs

示例2: GetValue

 public string GetValue(BsonValue value)
 {
     if (value.IsBsonNull)
         return "null";
     else
         return value.ToString();
 }
开发者ID:kulalexey,项目名称:PrettyLog,代码行数:7,代码来源:ShowObjectWindow.xaml.cs

示例3: OplogNamespace

        public OplogNamespace(BsonValue bsonValue)
        {
            if(bsonValue == null)
            {
                throw new MongoRiverException("Namespace not defined on document.");
            }

            BuildParts(bsonValue.ToString());
        }
开发者ID:andreimatusevich,项目名称:MongoRiver.NET,代码行数:9,代码来源:OplogNamespace.cs

示例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;
            }
        }
开发者ID:magicdict,项目名称:MongoCola,代码行数:60,代码来源:BsonValueEx.cs

示例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;
     }
 }
开发者ID:huohe2009,项目名称:MagicMongoDBTool,代码行数:27,代码来源:BsonValueEx.cs

示例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();
        }
开发者ID:kklik,项目名称:MagicMongoDBTool,代码行数:43,代码来源:MongoDBHelper_View.cs

示例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);
        }
开发者ID:jango2015,项目名称:MongoCola,代码行数:50,代码来源:CommandHelper.cs

示例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();
        }
开发者ID:peidachang,项目名称:MagicMongoDBTool,代码行数:40,代码来源:MongoDBHelper_View.cs

示例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;
         }
     }
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:73,代码来源:ctlBsonValue.cs

示例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;
         }
     }
 }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:71,代码来源:ctlBsonValue.cs

示例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;
        }
开发者ID:mastronardif,项目名称:WebApiLiteDB,代码行数:32,代码来源:MyLiteDB.cs

示例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);
        }
开发者ID:Eddie0330,项目名称:MagicMongoDBTool,代码行数:49,代码来源:MongoDBHelper_Command.cs

示例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);
                }
            }
        }
开发者ID:object,项目名称:MongOData,代码行数:37,代码来源:MongoDSPConverter.cs

示例14: ValueToString

        private string ValueToString(BsonValue value)
        {
            if (value == BsonNull.Value)
            {
                return null;
            }

            return value.ToString();
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:9,代码来源:TestRunner.cs

示例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;
 }
开发者ID:ironmp,项目名称:MongoView,代码行数:7,代码来源:DBForm.cs


注:本文中的BsonValue.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。