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


C# BsonWriter类代码示例

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


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


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