• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BsonValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BsonValue的典型用法代码示例。如果您正苦于以下问题:C# BsonValue类的具体用法?C# BsonValue怎么用?C# BsonValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BsonValue类属于命名空间,在下文中一共展示了BsonValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IndexKeysDocument

 public IndexKeysDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:7,代码来源:IndexKeysDocument.cs


示例2: Write

        public static void Write(this BsonDocument document, string field, BsonValue value)
        {

            if (value == null) return;

            if (field.StartsWith("_")) field = "PREFIX" + field;
            // todo: make sure the search query builder also picks up this name change.

            bool forcearray = (value.BsonType == BsonType.Document);
            // anders kan er op zo'n document geen $elemMatch gedaan worden.

            BsonElement element;

            if (document.TryGetElement(field, out element))
            {
                if (element.Value.BsonType == BsonType.Array)
                {
                    element.Value.AsBsonArray.Add(value);
                }
                else
                {
                    document.Remove(field);
                    document.Append(field, new BsonArray() { element.Value, value ?? BsonNull.Value });
                }
            }
            else
            {
                if (forcearray)
                    document.Append(field, new BsonArray() { value ?? BsonNull.Value });
                else
                    document.Append(field, value);
            }
        }
开发者ID:Condeti,项目名称:spark,代码行数:33,代码来源:BsonIndexDocument.cs


示例3: RemoveMatchingElements

 private void RemoveMatchingElements(BsonValue value, Regex regex)
 {
     if (value.BsonType == BsonType.Document)
     {
         var document = value.AsBsonDocument;
         foreach (var name in document.Names.ToList())
         {
             if (regex.IsMatch(name))
             {
                 document.Remove(name);
             }
             else
             {
                 RemoveMatchingElements(document[name], regex);
             }
         }
     }
     else if (value.BsonType == BsonType.Array)
     {
         foreach (var item in value.AsBsonArray)
         {
             RemoveMatchingElements(item, regex);
         }
     }
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:25,代码来源:ExplainTests.cs


示例4: SortByDocument

 public SortByDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:7,代码来源:SortByDocument.cs


示例5: Serialize

 /// <summary>
 /// Json serialize a BsonValue into a TextWriter
 /// </summary>
 public static void Serialize(BsonValue value, TextWriter writer, bool pretty = false, bool writeBinary = true)
 {
     var w = new JsonWriter(writer);
     w.Pretty = pretty;
     w.WriteBinary = writeBinary;
     w.Serialize(value ?? BsonValue.Null);
 }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:10,代码来源:JsonSerializer.cs


示例6: PreprocessHex

            private BsonValue PreprocessHex(BsonValue value)
            {
                var array = value as BsonArray;
                if (array != null)
                {
                    for (var i = 0; i < array.Count; i++)
                    {
                        array[i] = PreprocessHex(array[i]);
                    }
                    return array;
                }

                var document = value as BsonDocument;
                if (document != null)
                {
                    if (document.ElementCount == 1 && document.GetElement(0).Name == "$hex" && document[0].IsString)
                    {
                        var hex = document[0].AsString;
                        var bytes = BsonUtils.ParseHexString(hex);
                        return new BsonBinaryData(bytes);
                    }

                    for (var i = 0; i < document.ElementCount; i++)
                    {
                        document[i] = PreprocessHex(document[i]);
                    }
                    return document;
                }

                return value;
            }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:31,代码来源:GridFSTestRunner.cs


示例7: BulkWriteOperationUpsert

 // constructors
 internal BulkWriteOperationUpsert(
     int index,
     BsonValue id)
 {
     _index = index;
     _id = id;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BulkWriteOperationUpsert.cs


示例8: BsonValueMemberProvider

 public BsonValueMemberProvider(BsonValue value)
 {
     this.mValue = value;
     this.mPropsToWrite = mValue.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
         .Where(p => !IgnoredProperties.Contains(p.Name) && p.GetIndexParameters().Length == 0)
         .ToArray();
 }
开发者ID:gburgett,项目名称:LinqPad-mongo-driver,代码行数:7,代码来源:BsonValueMemberProvider.cs


示例9: CommandDocument

 public CommandDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:kolupaev,项目名称:mongo-csharp-driver,代码行数:7,代码来源:CommandDocument.cs


示例10: FormatMessage

 private static string FormatMessage(BsonValue id, long n, string reason)
 {
     Ensure.IsNotNull(id, nameof(id));
     Ensure.IsGreaterThanOrEqualToZero(n, nameof(n));
     Ensure.IsNotNull(reason, nameof(reason));
     return string.Format("GridFS chunk {0} of file id {1} is {2}.", n, id, reason);
 }
开发者ID:jefth,项目名称:mongo-csharp-driver,代码行数:7,代码来源:GridFSChunkException.cs


示例11: ExpressionQuery

        public static IMongoQuery ExpressionQuery(string name, Operator optor, BsonValue value)
        {
            switch (optor)
            {
                case Operator.EQ:
                    return M.Query.EQ(name, value);

                case Operator.GT:
                    return M.Query.GT(name, value);

                case Operator.GTE:
                    return M.Query.GTE(name, value);

                case Operator.ISNULL:
                    return M.Query.EQ(name, null);

                case Operator.LT:
                    return M.Query.LT(name, value);

                case Operator.LTE:
                    return M.Query.LTE(name, value);

                case Operator.NOTNULL:
                    return M.Query.NE(name, null);

                default:
                    throw new ArgumentException(String.Format("Invalid operator {0} on token parameter {1}", optor.ToString(), name));
            }
        }
开发者ID:raysearchlabs,项目名称:spark,代码行数:29,代码来源:CriteriaMongoExtensions.cs


示例12: ConvertValue

        private static object ConvertValue(string elementName, BsonValue value, IDictionary<string, string> aliases)
        {
            if (value.IsBsonDocument)
            {
                aliases = aliases.Where(x => x.Key.StartsWith(elementName + ".")).ToDictionary(x => x.Key.Remove(0, elementName.Length + 1), x => x.Value);
                return value.AsBsonDocument.ToSimpleDictionary(aliases);
            }
            else if (value.IsBsonArray)
                return value.AsBsonArray.Select(v => ConvertValue(elementName, v, aliases)).ToList();
            else if (value.IsBoolean)
                return value.AsBoolean;
            else if (value.IsDateTime)
                return value.AsDateTime;
            else if (value.IsDouble)
                return value.AsDouble;
            else if (value.IsGuid)
                return value.AsGuid;
            else if (value.IsInt32)
                return value.AsInt32;
            else if (value.IsInt64)
                return value.AsInt64;
            else if (value.IsObjectId)
                return value.AsObjectId;
            else if (value.IsString)
                return value.AsString;
            else if (value.BsonType == BsonType.Binary)
                 return value.AsByteArray;
 
            return value.RawValue;
        }
开发者ID:BraveNewMath,项目名称:Simple.Data.MongoDB,代码行数:30,代码来源:BsonDocumentExtensions.cs


示例13: 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


示例14: _assertRequired

 private static void _assertRequired(Property property, BsonValue value)
 {
     if (property.Options.Required && value == BsonNull.Value)
     {
         throw new ArgumentException("the property \"" + property.Name + "\" is required and connot be null");
     }
 }
开发者ID:r0flbear,项目名称:MongoInterface,代码行数:7,代码来源:DocumentValidator.cs


示例15: QueryDocument

 public QueryDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:7,代码来源:QueryDocument.cs


示例16: MapReduceOutput

 private MapReduceOutput(
     string option,
     BsonValue value
 ) {
     this.option = option;
     this.value = value;
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MapReduceOptionsBuilder.cs


示例17: GeoNearOptionsDocument

 public GeoNearOptionsDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:7,代码来源:GeoNearOptionsDocument.cs


示例18: 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


示例19: GroupByDocument

 public GroupByDocument(
     string name,
     BsonValue value
 )
     : base(name, value)
 {
 }
开发者ID:kolupaev,项目名称:mongo-csharp-driver,代码行数:7,代码来源:GroupByDocument.cs


示例20: EQ

 public static QueryComplete EQ(
     string name,
     BsonValue value
 )
 {
     return new QueryComplete(new BsonDocument(name, value));
 }
开发者ID:testn,项目名称:mongo-csharp-driver,代码行数:7,代码来源:QueryBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BsonWriter类代码示例发布时间:2022-05-24
下一篇:
C# BsonType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap