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


C# BsonValue类代码示例

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


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


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