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


C# Bson.BsonDocumentWrapper类代码示例

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


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

示例1: SaveRequestData

        public static void SaveRequestData(HttpContextBase context)
        {
            var url = context.Request.Url.ToString();

            var data = new BsonDocumentWrapper(new
            {
                //_id = ObjectId.GenerateNewId(),
                at = DateTime.UtcNow,
                url,
                method = context.Request.HttpMethod,
                headers = From(context.Request.Headers),
                clientIp = context.Request.UserHostAddress
            }).ToBsonDocument();
            if (context.Request.Form.Count > 0)
            {
                data.Add("form", From(context.Request.Form));
            }
            var cookies = From(context.Response.Cookies);
            if (cookies.Length > 0)
                data.Add("cookies", BsonArray.Create((IEnumerable)cookies));
            var referrer = context.Request.UrlReferrer;
            if (referrer != null)
                data.Add("referrer", referrer.ToString());

            try
            {
                DB.Database.GetCollection("requestsLog").Insert(data);
            }
            catch
            {
            }
        }
开发者ID:lgadi,项目名称:ZeeBi,代码行数:32,代码来源:RequestsLog.cs

示例2: TestAddNameValue

 public void TestAddNameValue()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument());
     Assert.AreEqual(false, wrapper.IsMaterialized);
     wrapper.Add("x", 1);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(1), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentWrapperTests.cs

示例3: MongoQueryMessage

 internal MongoQueryMessage(
     string collectionFullName,
     QueryFlags flags,
     int numberToSkip,
     int numberToReturn,
     object query,
     BsonDocumentWrapper fields
 )
     : this(collectionFullName, flags, numberToSkip, numberToReturn, query, fields, null)
 {
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoQueryMessage.cs

示例4: CreateProtocol

 //  methods
 protected override IWireProtocol<BsonDocument> CreateProtocol(IConnectionHandle connection, WriteRequest request)
 {
     var insertRequest = (InsertRequest)request;
     var wrapper = new BsonDocumentWrapper(insertRequest.Document, insertRequest.Serializer);
     var documentSource = new BatchableSource<BsonDocument>(new[] { wrapper });
     return new InsertWireProtocol<BsonDocument>(
         DatabaseName,
         CollectionName,
         WriteConcern,
         BsonDocumentSerializer.Instance,
         documentSource,
         connection.Description.MaxBatchCount,
         connection.Description.MaxMessageSize,
         continueOnError: false);               
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BulkInsertOperationEmulator.cs

示例5: TestTryGetValue

 public void TestTryGetValue()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     BsonValue value;
     var result = wrapper.TryGetValue("x", out value);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(true, result);
     Assert.AreEqual(new BsonInt32(1), value);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentWrapperTests.cs

示例6: TestTryGetElement

 public void TestTryGetElement()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     BsonElement element;
     var result = wrapper.TryGetElement("x", out element);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(true, result);
     Assert.AreEqual("x", element.Name);
     Assert.AreEqual(new BsonInt32(1), element.Value);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonDocumentWrapperTests.cs

示例7: TestToString

 public void TestToString()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var expected = "{ 'x' : 1 }".Replace("'", "\"");
     var s = wrapper.ToString();
     Assert.AreEqual(false, wrapper.IsMaterialized); // ToString just serializes, doesn't materialize
     Assert.AreEqual(expected, s);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentWrapperTests.cs

示例8: TestGetValueByName

 public void TestGetValueByName()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var value = wrapper.GetValue("x");
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(new BsonInt32(1), value);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentWrapperTests.cs

示例9: TestConstructorWithNullNominalTypeAndObjectAndIsUpdateDocument

 public void TestConstructorWithNullNominalTypeAndObjectAndIsUpdateDocument()
 {
     Assert.Throws<ArgumentNullException>(() => { var wrapper = new BsonDocumentWrapper(null, _c, false); });
 }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:4,代码来源:BsonDocumentWrapperTests.cs

示例10: TestConstructorWithNominalTypeAndObject

 public void TestConstructorWithNominalTypeAndObject()
 {
     var wrapper = new BsonDocumentWrapper(typeof(C), _c);
     var expected = "{ \"X\" : 1 }";
     Assert.AreEqual(expected, wrapper.ToJson());
 }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonDocumentWrapperTests.cs

示例11: TestConstructorWithObject

 public void TestConstructorWithObject()
 {
     var wrapper = new BsonDocumentWrapper(_c);
     var expected = "{ \"X\" : 1 }";
     Assert.AreEqual(expected, wrapper.ToJson());
 }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonDocumentWrapperTests.cs

示例12: TestRawValues

        public void TestRawValues()
        {
#pragma warning disable 618
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            var values = wrapper.RawValues.ToArray();
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, values.Length);

            wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
            Assert.AreEqual(false, wrapper.IsMaterialized);
            values = wrapper.RawValues.ToArray();
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, values.Length);
            Assert.AreEqual(1, values[0]);
#pragma warning restore
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonDocumentWrapperTests.cs

示例13: TestNames

        public void TestNames()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            var names = wrapper.Names.ToArray();
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, names.Length);

            wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
            Assert.AreEqual(false, wrapper.IsMaterialized);
            names = wrapper.Names.ToArray();
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, names.Length);
            Assert.AreEqual("x", names[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BsonDocumentWrapperTests.cs

示例14: TestMergeOverwrite

 public void TestMergeOverwrite()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var result = wrapper.Merge(new BsonDocument("x", 2), true);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreSame(wrapper, result);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(2), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonDocumentWrapperTests.cs

示例15: TestIndexerByName

        public void TestIndexerByName()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
            Assert.AreEqual(false, wrapper.IsMaterialized);
            var value = wrapper["x"];
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(new BsonInt32(1), value);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper["x"] = 1;
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs


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