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

C# Bson.BsonDocumentWrapper类代码示例

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

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



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


示例16: TestIndexer

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

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


示例17: TestGetValueByNameWithDefaultValue

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


示例18: TestGetEnumerator

 public void TestGetEnumerator()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var enumerator = wrapper.GetEnumerator();
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.IsTrue(enumerator.MoveNext());
     Assert.AreEqual("x", enumerator.Current.Name);
     Assert.AreEqual(new BsonInt32(1), enumerator.Current.Value);
     Assert.IsFalse(enumerator.MoveNext());
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonDocumentWrapperTests.cs


示例19: TestValues

        public void TestValues()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            var values = wrapper.Values.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.Values.ToArray();
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, values.Length);
            Assert.AreEqual(new BsonInt32(1), values[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BsonDocumentWrapperTests.cs


示例20: TestAddNameValueFactoryWithCondition

        public void TestAddNameValueFactoryWithCondition()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.Add("x", () => 1, false);
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, wrapper.ElementCount);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.Add("x", () => 1, true);
            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;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IO.BsonBinaryReader类代码示例发布时间:2022-05-26
下一篇:
C# Models.BankAccountDetails类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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