IFormatter 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供格式化序列化物件的功能。
public interface class IFormatter
public interface IFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public interface IFormatter
type IFormatter = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type IFormatter = interface
Public Interface IFormatter
- 衍生
- 屬性
備註
此介面必須由架構中 System.Runtime.Serialization 任何被識別為格式化器的類別實作。
控制自身序列化的物件可以透過實作介面 ISerializable 來實現。 要讓物件被序列化,你必須標記該物件為可序列化。 你可以透過套用可序列化屬性來做到這點。 如果圖中任何物件不可序列化,序列化將失敗。
給實施者的注意事項
所有格式化器都必須實作此介面。 用 Serialize(Stream, Object) 來序列化物件或物件圖。 用 Deserialize(Stream) 來反序列化串流,並建立原始物件或物件圖的克隆。
屬性
| 名稱 | Description |
|---|---|
| Binder |
取得或設定 在 SerializationBinder 反序列化期間執行型別查詢。 |
| Context |
取得或設定用於 StreamingContext 序列化和反序列化的 。 |
| SurrogateSelector |
取得或設定 被 SurrogateSelector 目前格式化器使用。 |
方法
| 名稱 | Description |
|---|---|
| Deserialize(Stream) |
將所提供串流的資料反序列化,並重建物件圖。 |
| Serialize(Stream, Object) |
將物件或物件圖,以給定根序列化至所提供的串流。 |