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


C# BsonValue.ToBsonDocument方法代碼示例

本文整理匯總了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;
        }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:26,代碼來源:FindTest.cs

示例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;
 }
開發者ID:kklik,項目名稱:MagicMongoDBTool,代碼行數:98,代碼來源:MongoDBHelper_View.cs

示例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();
        }
開發者ID:kklik,項目名稱:MagicMongoDBTool,代碼行數:43,代碼來源:MongoDBHelper_View.cs

示例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();
        }
開發者ID:peidachang,項目名稱:MagicMongoDBTool,代碼行數:40,代碼來源:MongoDBHelper_View.cs

示例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;
 }
開發者ID:seaman,項目名稱:MagicMongoDBTool,代碼行數:27,代碼來源:MongoDBHelpler_View.cs


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