System.Xml.Serialization Namespace

System.Xml.Serialization 命名空間 (Namespace) 包含用於將物件序列化為 XML 格式文件或資料流的類別。 The System.Xml.Serialization namespace contains classes that are used to serialize objects into XML format documents or streams.

類別

CodeExporter

表示可從資料結構之 XML 表示產生 Proxy 程式碼的類別。Represents a class that can generate proxy code from an XML representation of a data structure.

CodeIdentifier

提供可將輸入文字轉換成程式碼實體 (Entity) 之名稱的靜態方法。Provides static methods to convert input text into names for code entities.

CodeIdentifiers

針對由 .NET Framework 之 XML 序列化 (Serialization) 基礎結構所產生的相關程式碼實體 (Entity) 或型別對應,維護名稱群組。Maintains a group of names for related code entities or type mappings that are generated by the .NET Framework's XML serialization infrastructure.

ImportContext

描述結構描述集合要繫結至 .NET Framework 程式碼實體 (Entity) 的內容。Describes the context in which a set of schema is bound to .NET Framework code entities.

SchemaImporter

描述結構描述匯入工具。Describes a schema importer.

SoapAttributeAttribute

指定 XmlSerializer 必須將類別成員序列化為編碼的 SOAP 屬性。Specifies that the XmlSerializer must serialize the class member as an encoded SOAP attribute.

SoapAttributeOverrides

使用 XmlSerializer 將物件序列化或還原序列化為編碼的 SOAP 時,可讓您覆寫套用至屬性 (Property)、欄位和類別的屬性 (Attribute)。Allows you to override attributes applied to properties, fields, and classes when you use an XmlSerializer to serialize or deserialize an object as encoded SOAP.

SoapAttributes

表示用來控制 XmlSerializer 序列化與還原序列化 SOAP 方法的屬性 (Attribute) 物件集合。Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes SOAP methods.

SoapCodeExporter

從 WSDL 文件中定義之 SOAP 編碼訊息部分的內部型別對應資訊,產生型別和屬性 (Attribute) 宣告。Generates types and attribute declarations from internal type mapping information for SOAP-encoded message parts defined in a WSDL document.

SoapElementAttribute

指定公用成員值由 XmlSerializer 序列化為編碼 SOAP XML 項目。Specifies that the public member value be serialized by the XmlSerializer as an encoded SOAP XML element.

SoapEnumAttribute

控制 XmlSerializer 序列化列舉型別 (Enumeration) 成員的方式。Controls how the XmlSerializer serializes an enumeration member.

SoapIgnoreAttribute

表示 XmlSerializer 不要將公用欄位或公用讀取/寫入屬性值序列化。Instructs the XmlSerializer not to serialize the public field or public read/write property value.

SoapIncludeAttribute

允許 XmlSerializer 在將物件序列化或還原序列化為編碼 SOAP XML 時,辨認型別。Allows the XmlSerializer to recognize a type when it serializes or deserializes an object as encoded SOAP XML.

SoapReflectionImporter

從 .NET Framework 型別或 Web 服務方法資訊產生 SOAP 編碼訊息的對應。Generates mappings to SOAP-encoded messages from .NET Framework types or Web service method information.

SoapSchemaExporter

使用以 SOAP 編碼序列化之 .NET Framework 型別的 XML 結構描述資料型別定義,填入 (Populate) XmlSchema 物件。Populates XmlSchema objects with XML Schema data type definitions for .NET Framework types that are serialized using SOAP encoding.

SoapSchemaImporter

在 .NET Framework 中使用,以便針對 WSDL 文件中的 SOAP 編碼訊息部分產生 .NET Framework 型別的內部對應。Used within the .NET Framework to generate internal mappings to .NET Framework types for SOAP-encoded message parts in a WSDL document.

SoapSchemaMember

在 WSDL 文件中代表 XSD <part> 項目的特定屬性,可從文件產生類別。Represents certain attributes of a XSD <part> element in a WSDL document for generating classes from the document.

SoapTypeAttribute

控制類別執行個體被序列化為 SOAP 編碼 XML 時,XmlSerializer 所產生的結構描述。Controls the schema generated by the XmlSerializer when a class instance is serialized as SOAP encoded XML.

UnreferencedObjectEventArgs

提供在還原序列化 (Deserialization) 時,於編碼 SOAP XML 資料流中發現之已知,但是未被參考到的物件。Provides data for the known, but unreferenced, object found in an encoded SOAP XML stream during deserialization.

XmlAnyAttributeAttribute

指定成員 (傳回 XmlAttribute 物件陣列的欄位) 可以包含任何 XML 屬性。Specifies that the member (a field that returns an array of XmlAttribute objects) can contain any XML attributes.

XmlAnyElementAttribute

指定成員 (傳回 XmlElementXmlNode 物件陣列的欄位) 包含物件,該物件表示在序列化或還原序列化物件中沒有對應成員的任何 XML 項目。Specifies that the member (a field that returns an array of XmlElement or XmlNode objects) contains objects that represent any XML element that has no corresponding member in the object being serialized or deserialized.

XmlAnyElementAttributes

表示 XmlAnyElementAttribute 物件的集合。Represents a collection of XmlAnyElementAttribute objects.

XmlArrayAttribute

指定 XmlSerializer 必須將特定類別成員序列化為 XML 項目的陣列。Specifies that the XmlSerializer must serialize a particular class member as an array of XML elements.

XmlArrayItemAttribute

表示屬性,這個屬性會指定 XmlSerializer 可置於序列化陣列中的衍生型別。Represents an attribute that specifies the derived types that the XmlSerializer can place in a serialized array.

XmlArrayItemAttributes

表示 XmlArrayItemAttribute 物件的集合。Represents a collection of XmlArrayItemAttribute objects.

XmlAttributeAttribute

指定 XmlSerializer 必須將類別成員序列化為 XML 屬性。Specifies that the XmlSerializer must serialize the class member as an XML attribute.

XmlAttributeEventArgs

提供 UnknownAttribute 事件的資料。Provides data for the UnknownAttribute event.

XmlAttributeOverrides

當使用 XmlSerializer 來序列化或還原序列化物件時,允許您覆寫屬性 (Property)、欄位和類別屬性 (Attribute)。Allows you to override property, field, and class attributes when you use the XmlSerializer to serialize or deserialize an object.

XmlAttributes

表示用來控制 XmlSerializer 序列化與還原序列化物件方式的屬性 (Attribute) 物件集合。Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes an object.

XmlChoiceIdentifierAttribute

指定可以使用列舉型別進一步偵測成員。Specifies that the member can be further detected by using an enumeration.

XmlCodeExporter

從 XML 結構描述項目宣告的內部型別對應資訊,產生型別和屬性 (Attribute) 宣告。Generates types and attribute declarations from internal type mapping information for XML schema element declarations.

XmlElementAttribute

表示在 XmlSerializer 序列化或還原序列化包含 XML 項目的物件時,公用欄位或屬性表示該項目。Indicates that a public field or property represents an XML element when the XmlSerializer serializes or deserializes the object that contains it.

XmlElementAttributes

代表 XmlElementAttribute 物件的集合,由 XmlSerializer 用於覆寫其序列化類別的預設方式。Represents a collection of XmlElementAttribute objects used by the XmlSerializer to override the default way it serializes a class.

XmlElementEventArgs

提供 UnknownElement 事件的資料。Provides data for the UnknownElement event.

XmlEnumAttribute

控制 XmlSerializer 序列化列舉型別 (Enumeration) 成員的方式。Controls how the XmlSerializer serializes an enumeration member.

XmlIgnoreAttribute

表示 Serialize(TextWriter, Object)XmlSerializer 方法不要序列化公用欄位或公用讀取/寫入屬性值。Instructs the Serialize(TextWriter, Object) method of the XmlSerializer not to serialize the public field or public read/write property value.

XmlIncludeAttribute

XmlSerializer 在對物件進行序列化或還原序列化時,能夠辨識型別。Allows the XmlSerializer to recognize a type when it serializes or deserializes an object.

XmlMapping

支援 .NET Framework 型別與 XML 結構描述資料型別之間的對應。Supports mappings between .NET Framework types and XML Schema data types.

XmlMemberMapping

將 .NET Framework Web 服務方法中的程式碼實體 (Entity) 對應至 Web 服務描述語言 (WSDL) 訊息中的項目。Maps a code entity in a .NET Framework Web service method to an element in a Web Services Description Language (WSDL) message.

XmlMembersMapping

提供 .NET Framework Web 服務方法與針對 SOAP Web 服務所定義之 Web 服務描述語言 (WSDL) 訊息之間的對應。Provides mappings between .NET Framework Web service methods and Web Services Description Language (WSDL) messages that are defined for SOAP Web services.

XmlNamespaceDeclarationsAttribute

指定目標屬性、參數、傳回值或類別成員,包含與 XML 文件內使用之命名空間相關聯的前置詞。Specifies that the target property, parameter, return value, or class member contains prefixes associated with namespaces that are used within an XML document.

XmlNodeEventArgs

提供 UnknownNode 事件的資料。Provides data for the UnknownNode event.

XmlReflectionImporter

針對 .NET Framework 類型或 Web 服務方法資訊產生 XML 結構描述項目宣告的對應,包括 Web 服務描述語言 (WSDL) 文件中的常值 XML 結構描述定義 (XSD) 訊息部分。Generates mappings to XML schema element declarations, including literal XML Schema Definition (XSD) message parts in a Web Services Description Language (WSDL) document, for .NET Framework types or Web service method information.

XmlReflectionMember

提供 .NET Framework Web 服務方法中的程式碼實體 (Entity) 與針對 SOAP Web 服務所定義之 Web 服務描述語言 (WSDL) 訊息內容之間的對應。Provides mappings between code entities in .NET Framework Web service methods and the content of Web Services Description Language (WSDL) messages that are defined for SOAP Web services.

XmlRootAttribute

控制做為 XML 根項目之屬性目標的 XML 序列化。Controls XML serialization of the attribute target as an XML root element.

XmlSchemaEnumerator

啟用對 XmlSchema 物件集合的反覆運算。Enables iteration over a collection of XmlSchema objects.

XmlSchemaExporter

使用在型別對應物件中找到的 XML 結構描述項目宣告,填入 (Populate) XmlSchema 物件中。Populates XmlSchema objects with XML schema element declarations that are found in type mapping objects.

XmlSchemaImporter

針對 XML 結構描述項目宣告產生 .NET Framework 型別的內部對應,包括 WSDL 文件中的常值 (Literal) XSD 訊息部分。Generates internal mappings to .NET Framework types for XML schema element declarations, including literal XSD message parts in a WSDL document.

XmlSchemaProviderAttribute

套用至型別後,儲存傳回 XML 結構描述之型別的靜態方法名稱以及控制型別之序列化 (Serialization) 的 XmlQualifiedName (或用於匿名型別的 XmlSchemaType)。When applied to a type, stores the name of a static method of the type that returns an XML schema and a XmlQualifiedName (or XmlSchemaType for anonymous types) that controls the serialization of the type.

XmlSchemas

表示 XML 結構描述的集合。Represents the collection of XML schemas.

XmlSerializationGeneratedCode

抽象類別,XmlSerializationReaderXmlSerializationWriter 的基底類別,包含這兩個型別的通用方法。An abstract class that is the base class for XmlSerializationReader and XmlSerializationWriter and that contains methods common to both of these types.

XmlSerializationReader

依據 XmlSerializer 類別控制還原序列化。Controls deserialization by the XmlSerializer class.

XmlSerializationReader.CollectionFixup

包含 XmlSerializationCollectionFixupCallback 委派 (Delegate) 執行個體,並加上方法的輸入,同時提供方法的參數。Holds an XmlSerializationCollectionFixupCallback delegate instance, plus the method's inputs; also supplies the method's parameters.

XmlSerializationReader.Fixup

存放一個 XmlSerializationFixupCallback 委派執行個體,加上此方法的輸入資料;同時也當做此方法的參數。Holds an XmlSerializationFixupCallback delegate instance, plus the method's inputs; also serves as the parameter for the method.

XmlSerializationWriter

表示由 XmlSerializer 類別 (Class) 用來控制序列化 (Serialization) 的抽象類別。Represents an abstract class used for controlling serialization by the XmlSerializer class.

XmlSerializer

將物件序列化成為 XML 文件,以及從 XML 文件將物件還原序列化。Serializes and deserializes objects into and from XML documents. XmlSerializer 可讓您控制如何將物件編碼為 XML。The XmlSerializer enables you to control how objects are encoded into XML.

XmlSerializerAssemblyAttribute

套用至 Web 服務用戶端 Proxy 後,就可讓您指定含有自訂序列化程式的組件。Applied to a Web service client proxy, enables you to specify an assembly that contains custom-made serializers.

XmlSerializerFactory

建立具型別版本的 XmlSerializer,以進行更有效率的序列化 (Serialization)。Creates typed versions of the XmlSerializer for more efficient serialization.

XmlSerializerImplementation

為預先產生且具類型的序列化程式定義讀取器、寫入器和方法。Defines the reader, writer, and methods for pre-generated, typed serializers.

XmlSerializerNamespaces

將 XML 命名空間 (Namespace) 和 XmlSerializer 用來產生限定名稱的前置詞包含在 XML 文件執行個體中。Contains the XML namespaces and prefixes that the XmlSerializer uses to generate qualified names in an XML-document instance.

XmlSerializerVersionAttribute

表示序列化 (Serialization) 基礎結構已產生程式碼,而且在這項屬性 (Attribute) 套用至組件 (Assembly) 時,可重複使用此程式碼來提升效能。Signifies that the code was generated by the serialization infrastructure and can be reused for increased performance, when this attribute is applied to an assembly.

XmlTextAttribute

表示 XmlSerializer 在序列化或還原序列化包含它的類別之後,應該將成員視為 XML 文字。Indicates to the XmlSerializer that the member must be treated as XML text when the class that contains it is serialized or deserialized.

XmlTypeAttribute

控制由 XmlSerializer 序列化屬性 (Attribute) 目標後所產生的 XML 結構描述。Controls the XML schema that is generated when the attribute target is serialized by the XmlSerializer.

XmlTypeMapping

包含某個類型與其他類型的對應。Contains a mapping of one type to another.

結構

XmlDeserializationEvents

此類別所含欄位可將事件委派傳遞給 Deserialize 的安全執行緒 XmlSerializer 方法。Contains fields that can be used to pass event delegates to a thread-safe Deserialize method of the XmlSerializer.

介面

IXmlSerializable

為 XML 序列化和還原序列化提供自訂格式化。Provides custom formatting for XML serialization and deserialization.

IXmlTextParser

建立要讓 .NET Framework 基礎結構使用的 Normalized 屬性。Establishes a Normalized property for use by the .NET Framework infrastructure.

列舉

CodeGenerationOptions

指定在產生 .NET Framework 類型以便搭配 XML Web Service 使用時要使用的各種選項。Specifies various options to use when generating .NET Framework types for use with an XML Web Service.

XmlMappingAccess

指定某個對應為讀取、寫入或兩者皆有。Specifies whether a mapping is read, write, or both.

委派

UnreferencedObjectEventHandler

表示處理 UnreferencedObjectXmlSerializer 事件的方法。Represents the method that handles the UnreferencedObject event of an XmlSerializer.

XmlAttributeEventHandler

表示處理 UnknownAttribute 的方法。Represents the method that handles the UnknownAttribute

XmlElementEventHandler

表示處理 UnknownElementXmlSerializer 事件的方法。Represents the method that handles the UnknownElement event of an XmlSerializer.

XmlNodeEventHandler

表示處理 UnknownNodeXmlSerializer 事件的方法。Represents the method that handles the UnknownNode event of an XmlSerializer.

XmlSerializationCollectionFixupCallback

針對 SOAP 編碼之 XML 資料類型 (已對應至集合或列舉) 的還原序列化,XmlSerializer 類別所使用的委派。Delegate used by the XmlSerializer class for deserialization of SOAP-encoded XML data types that map to collections or enumerations.

XmlSerializationFixupCallback

針對 SOAP 編碼之 XML 資料類型的還原序列化,XmlSerializer 類別所使用的委派。Delegate used by the XmlSerializer class for deserialization of SOAP-encoded XML data.

XmlSerializationReadCallback

XmlSerializer 類別對 SOAP 編碼的非根 XML 資料進行類型還原序列化時所使用的委派。Delegate used by the XmlSerializer class for deserialization of types from SOAP-encoded, non-root XML data.

XmlSerializationWriteCallback

XmlSerializer 類別對 SOAP 編碼之非根 XML 資料中的型別進行序列化時所使用的委派。Delegate that is used by the XmlSerializer class for serialization of types from SOAP-encoded, non-root XML data.

備註

命名空間中的核心類別是XmlSerializer類別。The central class in the namespace is the XmlSerializer class. 若要使用這個類別,使用XmlSerializer建構函式來建立使用的物件型別序列化類別的執行個體。To use this class, use the XmlSerializer constructor to create an instance of the class using the type of the object to serialize. 一次XmlSerializer已建立,建立要序列化之物件的執行個體。Once an XmlSerializer is created, create an instance of the object to serialize. 您也必須建立的物件,將檔案寫入文件或資料流,例如StreamTextWriter,或XmlWriterYou must also create an object to write the file to a document or stream, such as a Stream, TextWriter, or XmlWriter. 您可以接著呼叫Serialize將物件轉換成 XML 文件的方法。You can then call the Serialize method to convert the object into an XML document.

若要還原序列化來自 XML 文件的物件,建立適當的物件,以便讀取的文件或資料流 (同樣地, StreamTextWriter,或XmlWriter)。To deserialize an object from an XML document, create a suitable object to read the document or stream (again, a Stream, TextWriter, or XmlWriter). 叫用Deserialize方法並將產生的物件 (也就序列化) 的原始物件的型別轉型。Invoke the Deserialize method while casting the resulting object to the type of the original object (that was serialized).

若要進一步控制序列化中,System.Xml.Serialization命名空間包含數個Attribute可以套用至類別的成員的類別。To further control the serialization, the System.Xml.Serialization namespace contains several Attribute classes that can be applied to members of a class. 例如,如果類別包含的成員,將會序列化成 XML 項目,您可以套用XmlElementAttribute屬性的成員。For example, if a class contains a member that will be serialized as an XML element, you can apply the XmlElementAttribute attribute to the member. 當套用屬性,您可以指定詳細資料,例如實際 XML 項目名稱使用ElementName屬性。When applying the attribute, you can specify details such as the actual XML element name using the ElementName property. 如需所有屬性的完整清單,請參閱XmlSerializer類別概觀。For a complete list of all the attributes, see the XmlSerializer class overview.