SerializeExtendReadBsonT(Stream) Method

讀取Bson資料流反序列化為物件

Definition

Namespace: eBizprise.Framework
Assembly: eBizprise.Framework.SerializeHelper (in eBizprise.Framework.SerializeHelper.dll) Version: 25.0.0.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
C#
public static T ReadBson<T>(
	this Stream stream
)

Parameters

stream  Stream
資料流

Type Parameters

T
物件類型

Return Value

T
T

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Stream. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

以Bson格式讀取資料流內容轉換為指定類型的物件

Example

C#
TestClass testClass = new TestClass() { DecimalColumn = (decimal)3.3, IntColumn = 2, StringColumn = "Data" };

using (MemoryStream memoryStream = new MemoryStream())
{
    memoryStream.WriteBson(testClass);

    TestClass result = memoryStream.ReadBson<TestClass>(JsonOption.IncludeNull);
}

/// 
/// 測試類別
/// 
class TestClass
{
    /// 
    /// 文字欄位
    /// 
    public string StringColumn { get; set; }
    /// 
    /// 整數欄位
    /// 
    public int IntColumn { get; set; }
    /// 
    /// 數字欄位
    /// 
    public decimal DecimalColumn { get; set; }
    /// 
    /// 二進位欄位
    /// 
    public byte[] ByteColumn { get; set; }
}

Revision History

DateVersionDescription
2020/02/071.0.0.0初版
2025/09/1925.0.0.0彙整2025年度初版

See Also