System.Runtime.Serialization Namespace

System.Runtime.Serialization 命名空间包含可用于将对象序列化和反序列化的类。 The System.Runtime.Serialization namespace contains classes that can be used for serializing and deserializing objects. 序列化是将对象或对象图转换为线性的字节序列以存储或传输到其他位置的过程。 Serialization is the process of converting an object or a graph of objects into a linear sequence of bytes for either storage or transmission to another location. 反序列化是接受存储的信息并从该信息重新创建对象的过程。 Deserialization is the process of taking in stored information and recreating objects from it.

CollectionDataContractAttribute

当应用于集合类型时,可用来对集合项元素进行自定义指定。When applied to a collection type, enables custom specification of the collection item elements. 此属性只能应用于被 DataContractSerializer 视为有效的可序列化集合的类型。This attribute can be applied only to types that are recognized by the DataContractSerializer as valid, serializable collections.

ContractNamespaceAttribute

指定数据协定的 CLR 命名空间和 XML 命名空间。Specifies the CLR namespace and XML namespace of the data contract.

DataContractAttribute

指定该类型要定义或实现一个数据协定,并可由序列化程序(如 DataContractSerializer)进行序列化。Specifies that the type defines or implements a data contract and is serializable by a serializer, such as the DataContractSerializer. 若要使其类型可序列化,类型作者必须为其类型定义数据协定。To make their type serializable, type authors must define a data contract for their type.

DataContractResolver

提供一种机制,用于在序列化和反序列化期间在类型和 xsi:type 表示形式之间动态进行相互映射。Provides a mechanism for dynamically mapping types to and from xsi:type representations during serialization and deserialization.

DataContractSerializer

使用提供的数据协定,将类型实例序列化和反序列化为 XML 流或文档。Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract. 此类不能被继承。This class cannot be inherited.

DataContractSerializerExtensions

通过提供用于设置和获取 ISerializationSurrogateProvider 的方法来扩展 DataContractSerializer 类。Extends the DataContractSerializer class by providing methods for setting and getting an ISerializationSurrogateProvider.

DataContractSerializerSettings

指定数据协定序列化程序设置。Specifies data contract serializer settings.

DataMemberAttribute

当应用于类型的成员时,指定该成员是数据协定的一部分并可由 DataContractSerializer 进行序列化。When applied to the member of a type, specifies that the member is part of a data contract and is serializable by the DataContractSerializer.

DateTimeFormat

指定日期时间格式选择。Specifies date-time format options.

EnumMemberAttribute

指定字段为枚举成员并且应该序列化。Specifies that the field is an enumeration member and should be serialized.

ExportOptions

表示可为 XsdDataContractExporter 设置的选项。Represents the options that can be set for an XsdDataContractExporter.

ExtensionDataObject

存储已经通过添加新成员扩展的版本化数据协定中的数据。Stores data from a versioned data contract that has been extended by adding new members.

Formatter

提供公共语言运行时序列化格式化程序的基本功能。Provides base functionality for the common language runtime serialization formatters.

FormatterConverter

表示 IFormatterConverter 接口的基实现,该接口使用 Convert 类和 IConvertible 接口。Represents a base implementation of the IFormatterConverter interface that uses the Convert class and the IConvertible interface.

FormatterServices

提供静态方法,以协助实现用于序列化的 FormatterProvides static methods to aid with the implementation of a Formatter for serialization. 此类不能被继承。This class cannot be inherited.

IgnoreDataMemberAttribute

当应用于类型的成员时,指定该成员不是数据协定的一部分且没有进行序列化。When applied to the member of a type, specifies that the member is not part of a data contract and is not serialized.

ImportOptions

表示可对 XsdDataContractImporter 设置的选项。Represents the options that can be set on an XsdDataContractImporter.

InvalidDataContractException

DataContractSerializerNetDataContractSerializer 在序列化和反序列化的过程中遇到无效的数据协定时引发的异常。The exception that is thrown when the DataContractSerializer or NetDataContractSerializer encounters an invalid data contract during serialization and deserialization.

KnownTypeAttribute

指定 DataContractSerializer 在序列化或反序列化给定类型时应识别的类型。Specifies types that should be recognized by the DataContractSerializer when serializing or deserializing a given type.

NetDataContractSerializer

使用提供的 .NET Framework 类型,将类型实例序列化和反序列化为 XML 流或文档。Serializes and deserializes an instance of a type into XML stream or document using the supplied .NET Framework types. 此类不能被继承。This class cannot be inherited.

ObjectIDGenerator

生成对象的 ID。Generates IDs for objects.

ObjectManager

在对象进行反序列化时对其进行跟踪。Keeps track of objects as they are deserialized.

OnDeserializedAttribute

如果将对象图中的对象应用于某方法,则应指定在反序列化该对象图后立即调用该方法。When applied to a method, specifies that the method is called immediately after deserialization of an object in an object graph. 相对于关系图中的其他对象,该反序列化的顺序是不确定的。The order of deserialization relative to other objects in the graph is non-deterministic.

OnDeserializingAttribute

当应用于方法时,指定在反序列化对象关系图中的对象期间调用该方法。When applied to a method, specifies that the method is called during deserialization of an object in an object graph. 相对于关系图中的其他对象,该反序列化的顺序是不确定的。The order of deserialization relative to other objects in the graph is non-deterministic.

OnSerializedAttribute

当应用于方法时,指定在序列化对象关系图中的对象之后调用该方法。When applied to a method, specifies that the method is called after serialization of an object in an object graph. 相对于关系图中的其他对象,序列化的顺序是不确定的。The order of serialization relative to other objects in the graph is non-deterministic.

OnSerializingAttribute

当应用于方法时,指定在序列化对象关系图中的对象期间调用该方法。When applied to a method, specifies that the method is during serialization of an object in an object graph. 相对于关系图中的其他对象,序列化的顺序是不确定的。The order of serialization relative to other objects in the graph is non-deterministic.

OptionalFieldAttribute

指定序列化流中可以缺少一个字段,这样 BinaryFormatterSoapFormatter 就不会引发异常。Specifies that a field can be missing from a serialization stream so that the BinaryFormatter and the SoapFormatter does not throw an exception.

SafeSerializationEventArgs

SerializeObjectState 事件提供数据。Provides data for the SerializeObjectState event.

SerializationBinder

允许用户控制类加载并指定要加载的类。Allows users to control class loading and mandate what class to load.

SerializationException

在序列化或反序列化期间出错时所引发的异常。The exception thrown when an error occurs during serialization or deserialization.

SerializationInfo

存储对对象进行序列化或反序列化所需的全部数据。Stores all the data needed to serialize or deserialize an object. 此类不能被继承。This class cannot be inherited.

SerializationInfoEnumerator

提供适用于格式化程序的机制,用于分析 SerializationInfo 中的数据。Provides a formatter-friendly mechanism for parsing the data in SerializationInfo. 此类不能被继承。This class cannot be inherited.

SerializationObjectManager

在运行时管理序列化过程。Manages serialization processes at run time. 此类不能被继承。This class cannot be inherited.

SurrogateSelector

帮助格式化程序选择要将序列化或反序列化进程委托给的序列化代理项。Assists formatters in selection of the serialization surrogate to delegate the serialization or deserialization process to.

XmlObjectSerializer

提供用于将对象序列化为 XML 流或文档的基类。Provides the base class used to serialize objects as XML streams or documents. 此类为抽象类。This class is abstract.

XmlSerializableServices

包含用于读取和编写 XML 的方法。Contains methods for reading and writing XML.

XPathQueryGenerator

给定表示数据协定的类和表示此协定的某个成员的元数据时,会为该成员生成 Xpath 查询。When given a class representing a data contract, and metadata representing a member of the contract, produces an XPath query for the member.

XsdDataContractExporter

用于将数据协定中使用的一组 .NET Framework 类型转换成 XML 架构文件 (.xsd)。Allows the transformation of a set of .NET Framework types that are used in data contracts into an XML schema file (.xsd).

XsdDataContractImporter

用于将一组 XML 架构文件 (.xsd) 转换为公共语言运行库 (CLR) 类型。Allows the transformation of a set of XML schema files (.xsd) into common language runtime (CLR) types.

结构

SerializationEntry

包含序列化对象的 Type 值以及名称。Holds the value, Type, and name of a serialized object.

StreamingContext

描述给定的序列化流的源和目标,并提供一个由调用方定义的附加上下文。Describes the source and destination of a given serialized stream, and provides an additional caller-defined context.

接口

IDataContractSurrogate

提供 DataContractSerializer 在序列化、反序列化以及导出和导入 XML 架构文档 (XSD) 的过程中将一种类型替换为另一种类型所需的方法。Provides the methods needed to substitute one type for another by the DataContractSerializer during serialization, deserialization, and export and import of XML schema documents (XSD).

IDeserializationCallback

指示在完成整个对象图形的反序列化时通知类。Indicates that a class is to be notified when deserialization of the entire object graph has been completed. 注意当用 XmlSerializer (System.Xml.Serialization.XmlSerializer) 反序列化时,不调用此接口。Note that this interface is not called when deserializing with the XmlSerializer (System.Xml.Serialization.XmlSerializer).

IExtensibleDataObject

提供一个数据结构,用于存储 XmlObjectSerializer 在反序列化一个用 DataContractAttribute 属性标记的类型期间遇到的额外数据。Provides a data structure to store extra data encountered by the XmlObjectSerializer during deserialization of a type marked with the DataContractAttribute attribute.

IFormatter

提供用于格式化串行化对象的功能。Provides functionality for formatting serialized objects.

IFormatterConverter

提供 SerializationInfo 的实例与格式化程序所提供的、最适用于分析 SerializationInfo 中的数据的类之间的连接。Provides the connection between an instance of SerializationInfo and the formatter-provided class best suited to parse the data inside the SerializationInfo.

IObjectReference

指示当前接口实施者是对另一个对象的引用。Indicates that the current interface implementer is a reference to another object.

ISafeSerializationData

启用安全透明的代码中的自定义异常数据的序列化。Enables serialization of custom exception data in security-transparent code.

ISerializable

允许对象控制其自己的序列化和反序列化过程。Allows an object to control its own serialization and deserialization.

ISerializationSurrogate

实现序列化代理项选择器,此选择器允许一个对象对另一个对象执行序列化和反序列化。Implements a serialization surrogate selector that allows one object to perform serialization and deserialization of another.

ISerializationSurrogateProvider

提供构造用于扩展 DataContractSerializer 的序列化代理项所需的方法。Provides the methods needed to construct a serialization surrogate that extends the DataContractSerializer. 在序列化和反序列化期间,使用序列化代理项将一种类型替换为另一类型。A serialization surrogate is used during serialization and deserialization to substitute one type for another.

ISurrogateSelector

指示序列化代理项选择器类。Indicates a serialization surrogate selector class.

枚举

EmitTypeInformation

指定发出类型信息的频率。Specifies how often to emit type information.

StreamingContextStates

定义指定序列化期间流的源或目标上下文的一组标志。Defines a set of flags that specifies the source or destination context for the stream during serialization.

注解

通过 ISerializable 接口,类可以执行其自己的序列化行为。The ISerializable interface provides a way for classes to control their own serialization behavior. 中的类System.Runtime.Serialization.Formatters命名空间控制实际封装在序列化对象的各种数据类型的格式。Classes in the System.Runtime.Serialization.Formatters namespace control the actual formatting of various data types encapsulated in the serialized objects.

可序列化和反序列化对象和特定格式的格式化程序可在System.Runtime.Serialization.Formatters命名空间。Formatters that serialize and deserialize objects to and from a particular format can be found in the System.Runtime.Serialization.Formatters namespace.