XmlSerializer.GenerateSerializer 方法

定义

返回一个程序集,其中包含类型化的序列化程序。Returns an assembly that contains typed serializers.

重载

GenerateSerializer(Type[], XmlMapping[])

使用指定映射返回一个程序集,该程序集包含的自定义序列化程序用于序列化或反序列化指定的一个或多个类型。Returns an assembly that contains custom-made serializers used to serialize or deserialize the specified type or types, using the specified mappings.

GenerateSerializer(Type[], XmlMapping[], CompilerParameters)

使用指定映射、编译器设置和选项返回一个程序集,该程序集包含的自定义序列化程序用于序列化或反序列化指定的一个或多个类型。Returns an assembly that contains custom-made serializers used to serialize or deserialize the specified type or types, using the specified mappings and compiler settings and options.

注解

XML 序列化程序生成器工具(Sgen)为指定程序集中的类型创建 XML 序列化程序集,以便在序列化或反序列化指定类型的对象时提高 XmlSerializer 的运行时性能。The XML Serializer Generator Tool (Sgen.exe) creates an XML serialization assembly for types in a specified assembly to improve the run-time performance of an XmlSerializer when it serializes or deserializes objects of the specified types. 使用 GetXmlSerializerAssemblyName 返回此类程序集的名称。Use the GetXmlSerializerAssemblyName to return the name of such an assembly.

如果要将此类程序集作为调用 Web 服务的客户端应用程序的一部分进行分发,则可以将 XmlSerializerAssemblyAttribute 应用于客户端类型以指定程序集的位置和名称。If you are distributing such an assembly as part of a client application that calls a Web service, you can apply the XmlSerializerAssemblyAttribute to the client type to specify the location and name of the assembly.

GenerateSerializer(Type[], XmlMapping[])

使用指定映射返回一个程序集,该程序集包含的自定义序列化程序用于序列化或反序列化指定的一个或多个类型。Returns an assembly that contains custom-made serializers used to serialize or deserialize the specified type or types, using the specified mappings.

public:
 static System::Reflection::Assembly ^ GenerateSerializer(cli::array <Type ^> ^ types, cli::array <System::Xml::Serialization::XmlMapping ^> ^ mappings);
public static System.Reflection.Assembly GenerateSerializer (Type[] types, System.Xml.Serialization.XmlMapping[] mappings);
static member GenerateSerializer : Type[] * System.Xml.Serialization.XmlMapping[] -> System.Reflection.Assembly
Public Shared Function GenerateSerializer (types As Type(), mappings As XmlMapping()) As Assembly

参数

types
Type[]

类型集合。A collection of types.

mappings
XmlMapping[]

一个 XmlMapping 对象的集合,用于将一个类型转换为另一个类型。A collection of XmlMapping objects used to convert one type to another.

返回

一个 Assembly 对象,包含提供的类型和映射的序列化程序。An Assembly object that contains serializers for the supplied types and mappings.

GenerateSerializer(Type[], XmlMapping[], CompilerParameters)

使用指定映射、编译器设置和选项返回一个程序集,该程序集包含的自定义序列化程序用于序列化或反序列化指定的一个或多个类型。Returns an assembly that contains custom-made serializers used to serialize or deserialize the specified type or types, using the specified mappings and compiler settings and options.

public:
 static System::Reflection::Assembly ^ GenerateSerializer(cli::array <Type ^> ^ types, cli::array <System::Xml::Serialization::XmlMapping ^> ^ mappings, System::CodeDom::Compiler::CompilerParameters ^ parameters);
public static System.Reflection.Assembly GenerateSerializer (Type[] types, System.Xml.Serialization.XmlMapping[] mappings, System.CodeDom.Compiler.CompilerParameters parameters);
static member GenerateSerializer : Type[] * System.Xml.Serialization.XmlMapping[] * System.CodeDom.Compiler.CompilerParameters -> System.Reflection.Assembly
Public Shared Function GenerateSerializer (types As Type(), mappings As XmlMapping(), parameters As CompilerParameters) As Assembly

参数

types
Type[]

一个 Type 类型的数组,其中包含的对象用于对数据进行序列化和反序列化。An array of type Type that contains objects used to serialize and deserialize data.

mappings
XmlMapping[]

一个 XmlMapping 类型的数组,它将 XML 数据映射到类型数据。An array of type XmlMapping that maps the XML data to the type data.

parameters
CompilerParameters

CompilerParameters 类的实例,表示用于调用编译器的参数。An instance of the CompilerParameters class that represents the parameters used to invoke a compiler.

返回

Assembly 包含 XmlSerializer 的专用版本。An Assembly that contains special versions of the XmlSerializer.

适用于