當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。