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