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

C# BsonWriter类代码示例

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

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



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

示例1: Serialize

		public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
		{
			if (IsRelationalAssociation(bsonWriter, value))
				RelationSerializer.Instance.Serialize(bsonWriter, nominalType, value, options);
			else
				CustomBsonClassMapSerializer.Instance.Serialize(bsonWriter, nominalType, value, options);
		}
开发者ID:modulexcite,项目名称:ormongo,代码行数:7,代码来源:DocumentSerializer.cs


示例2: Serialize

        public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
        {
            IDictionary<string, object> obj = value as IDictionary<string, object>;
            if (obj == null)
            {
                bsonWriter.WriteNull();
                return;
            }

            bsonWriter.WriteStartDocument();
            foreach (var member in obj)
            {
                bsonWriter.WriteName(member.Key);
                object memberValue = member.Value;

                if (memberValue == null)
                {
                    bsonWriter.WriteNull();
                }
                else
                {
                    nominalType = memberValue.GetType();
                    var serializer = BsonSerializer.LookupSerializer(nominalType);
                    serializer.Serialize(bsonWriter, nominalType, memberValue, options);
                }
            }
            bsonWriter.WriteEndDocument();
        }
开发者ID:abel,项目名称:sinan,代码行数:28,代码来源:VariantBsonSerializer.cs


示例3: Serialize

        public override void Serialize(
			BsonWriter bsonWriter,
			Type nominalType,
			object value,
			IBsonSerializationOptions options
			)
        {
            if (value == null)
            {
                bsonWriter.WriteNull();
                return;
            }

            var nvc = (NameValueCollection)value;

            bsonWriter.WriteStartArray();
            foreach (var key in nvc.AllKeys)
            {
                foreach (var val in nvc.GetValues(key))
                {
                    bsonWriter.WriteStartArray();
                    StringSerializer.Instance.Serialize(bsonWriter, typeof(string), key, options);
                    StringSerializer.Instance.Serialize(bsonWriter, typeof(string), val, options);
                    bsonWriter.WriteEndArray();
                }
            }
            bsonWriter.WriteEndArray();
        }
开发者ID:CaptainCodeman,项目名称:elmah-mongodb,代码行数:28,代码来源:NameValueCollectionSerializer.cs


示例4: IsRelationalAssociation

		private static bool IsRelationalAssociation(BsonWriter bsonWriter, object value)
		{
			if (value == null || bsonWriter.State != BsonWriterState.Value)
				return false;

			return IsRelationalType(value.GetType());
		}
开发者ID:modulexcite,项目名称:ormongo,代码行数:7,代码来源:DocumentSerializer.cs


示例5: WriteBson

		private void WriteBson(BsonWriter writer, Regex regex)
		{
			// Regular expression - The first cstring is the regex pattern, the second
			// is the regex options string. Options are identified by characters, which 
			// must be stored in alphabetical order. Valid options are 'i' for case 
			// insensitive matching, 'm' for multiline matching, 'x' for verbose mode, 
			// 'l' to make \w, \W, etc. locale dependent, 's' for dotall mode 
			// ('.' matches everything), and 'u' to make \w, \W, etc. match unicode.

			string options = null;

			if (HasFlag(regex.Options, RegexOptions.IgnoreCase))
				options += "i";

			if (HasFlag(regex.Options, RegexOptions.Multiline))
				options += "m";

			if (HasFlag(regex.Options, RegexOptions.Singleline))
				options += "s";

			options += "u";

			if (HasFlag(regex.Options, RegexOptions.ExplicitCapture))
				options += "x";

			writer.WriteRegex(regex.ToString(), options);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:27,代码来源:RegexConverter.cs


示例6: Serialize

		public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
		{
			var idPropertyInfo = value.GetType().GetProperty("ID");
			var id = (ObjectId) idPropertyInfo.GetValue(value, null);
			if (id == ObjectId.Empty)
				throw new Exception("Relational associations must be saved before saving the parent relation");
			ObjectIdSerializer.Instance.Serialize(bsonWriter, id.GetType(), id, options);
		}
开发者ID:modulexcite,项目名称:ormongo,代码行数:8,代码来源:RelationSerializer.cs


示例7: Serialize

 void IBsonSerializable.Serialize(
     BsonWriter bsonWriter,
     Type nominalType,
     bool serializeIdFirst
 )
 {
     Serialize(bsonWriter, nominalType, serializeIdFirst);
 }
开发者ID:testn,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BuilderBase.cs


示例8: WriteBody

 protected override void WriteBody(BsonWriter writer)
 {
     writer.WriteValue(BsonDataType.Integer,0);
     writer.WriteString(this.FullCollectionName);
     writer.WriteValue(BsonDataType.Integer,this.Flags);
     writer.Write(selector);
     writer.Write(Document);
 }
开发者ID:sdether,项目名称:mongodb-csharp,代码行数:8,代码来源:UpdateMessage.cs


示例9: Serialize

 public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
 {
     var c = (C)value;
     bsonWriter.WriteStartDocument();
     bsonWriter.WriteString("nominalType", nominalType.Name);
     bsonWriter.WriteInt32("X", c.X);
     bsonWriter.WriteEndDocument();
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentWrapperTests.cs


示例10: Serialize

 protected override void Serialize(
     BsonWriter bsonWriter,
     Type nominalType,
     bool serializeIdFirst
 )
 {
     document.Serialize(bsonWriter, nominalType, serializeIdFirst);
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:8,代码来源:GroupByBuilder.cs


示例11: TestCalculateSizeOfEmptyDoc

        public void TestCalculateSizeOfEmptyDoc()
        {
            Document doc = new Document();
            MemoryStream ms = new MemoryStream();
            BsonWriter writer = new BsonWriter(ms);

            Assert.AreEqual(5,writer.CalculateSize(doc));
        }
开发者ID:sdether,项目名称:mongodb-csharp,代码行数:8,代码来源:TestBsonWriter.cs


示例12: Serialize

 public void Serialize(
     BsonWriter bsonWriter,
     Type nominalType, // ignored
     bool serializeIdFirst
 )
 {
     BsonSerializer.Serialize(bsonWriter, this.nominalType, obj, serializeIdFirst); // use wrapped nominalType
 }
开发者ID:swiggin1,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BaseWrapper.cs


示例13: Serialize

 void IBsonSerializable.Serialize(
     BsonWriter bsonWriter,
     Type nominalType,
     IBsonSerializationOptions options
 )
 {
     Serialize(bsonWriter, nominalType, options);
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BuilderBase.cs


示例14: Serialize

 public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
 {
     int intValue;
     if (value is string && int.TryParse((string)value, out intValue))
         bsonWriter.WriteInt32(intValue);
     else
         throw new InvalidOperationException();
 }
开发者ID:hitesh97,项目名称:fluent-mongo,代码行数:8,代码来源:StringInt32Serializer.cs


示例15: Serialize

 public void Serialize(
     BsonWriter bsonWriter,
     Type nominalType, // ignored
     IBsonSerializationOptions options
 )
 {
     BsonSerializer.Serialize(bsonWriter, this.nominalType, obj, options); // use wrapped nominalType
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BaseWrapper.cs


示例16: Serialize

 public override void Serialize(
     BsonWriter bsonWriter,
     Type nominalType,
     object value,
     IBsonSerializationOptions options
 ) {
     var dateTime = (DateTime) value;
     bsonWriter.WriteString(dateTime.ToString("yyyy-MM-dd"));
 }
开发者ID:kamiff,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDefaultSerializerTests.cs


示例17: WriteBody

 protected override void WriteBody(Stream stream)
 {
     BsonWriter writer = new BsonWriter(stream);
     writer.Write((int)0);
     writer.Write(this.FullCollectionName);
     writer.Write(this.Upsert);
     selector.Write(writer);
     document.Write(writer);
 }
开发者ID:sbos,项目名称:mongodb-csharp,代码行数:9,代码来源:UpdateMessage.cs


示例18: Serialize

 public void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
 {
     var timeOfDay = (TimeOfDay)value;
     bsonWriter.WriteStartDocument();
     bsonWriter.WriteInt32("Hour", timeOfDay.Hour);
     bsonWriter.WriteInt32("Minute", timeOfDay.Minute);
     bsonWriter.WriteInt32("Second", timeOfDay.Second);
     bsonWriter.WriteEndDocument();
 }
开发者ID:Jiangew,项目名称:quartz.net-mongodb,代码行数:9,代码来源:TimeOfDaySerializer.cs


示例19: CalculateBodySize

 protected override int CalculateBodySize(BsonWriter writer)
 {
     int size = 4; //first int32
     size += writer.CalculateSize(this.FullCollectionName,false);
     size += 4; //flags
     size += writer.CalculateSize(this.Selector);
     size += writer.CalculateSize(this.Document);
     return size;
 }
开发者ID:sdether,项目名称:mongodb-csharp,代码行数:9,代码来源:UpdateMessage.cs


示例20: Serialize

 public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
 {
     if (value == null)
     {
         bsonWriter.WriteNull();
     }
     else
     {
         ObjectIdSerializer.Instance.Serialize(bsonWriter, nominalType, IdentifierFinder.GetId(value), options);
     }
 }
开发者ID:virajs,项目名称:MongoDB-Mapping-Attributes,代码行数:11,代码来源:ManyToOneBsonSerializer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BtCursor类代码示例发布时间:2022-05-24
下一篇:
C# BsonValue类代码示例发布时间: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