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

获取或设置在反序列化过程中执行类型查找的 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)

反序列化所提供流中的数据并重新组成对象图形。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)

将对象或具有给定根的对象图形序列化为所提供的流。Serializes an object, or graph of objects with the given root to the provided stream.

适用于

另请参阅