IFormatter IFormatter IFormatter IFormatter Interface

定義

提供用於格式化已序列化物件的功能。Provides functionality for formatting serialized objects.

public interface class IFormatter
[System.Runtime.InteropServices.ComVisible(true)]
public interface IFormatter
type IFormatter = interface
Public Interface IFormatter
衍生
屬性

備註

識別做為格式子中的任何類別必須實作這個介面System.Runtime.Serialization架構。This interface must be implemented by any class identified as a formatter in the System.Runtime.Serialization architecture.

物件控制自己的序列化可以達到此目的實作ISerializable介面。Objects controlling their own serialization can do so by implementing the ISerializable interface. 為了讓要序列化的物件,您必須將標記為可序列化該物件。In order for an object to be serialized, you must mark that object as being serializable. 您可以將可序列化的屬性套用至類別來執行這項操作。You can do this by applying the serializable attribute to a class. 如果圖形中的任何物件不是可序列化的則序列化會失敗。If any object in the graph is not serializable, serialization will fail.

給實施者的注意事項

所有的格式器必須實作這個介面。All formatters must implement this interface. 使用Serialize(Stream, Object)來序列化物件圖形。Use Serialize(Stream, Object) to serialize an object or graph of objects. 使用Deserialize(Stream)以還原序列化資料流,並建立原始的物件或物件圖形的複製品。Use Deserialize(Stream) to deserialize a stream and create a clone of the original object or graph of objects.

屬性

Binder Binder Binder Binder

取得或設定在還原序列化 (Deserialization) 期間執行型別查閱的 SerializationBinderGets or sets the SerializationBinder that performs type lookups during deserialization.

Context Context Context Context

取得或設定用於序列化和還原序列化的 StreamingContextGets or sets the StreamingContext used for serialization and deserialization.

SurrogateSelector SurrogateSelector SurrogateSelector SurrogateSelector

取得或設定目前格式子所使用的 SurrogateSelectorGets or sets the SurrogateSelector used by the current formatter.

方法

Deserialize(Stream) Deserialize(Stream) Deserialize(Stream) Deserialize(Stream)

還原序列化在提供的資料流上的資料,並重新組合物件 Graph。Deserializes the data on the provided stream and reconstitutes the graph of objects.

Serialize(Stream, Object) Serialize(Stream, Object) Serialize(Stream, Object) Serialize(Stream, Object)

使用所提供資料流的指定根序列化物件或物件 Graph。Serializes an object, or graph of objects with the given root to the provided stream.

適用於

另請參閱