IDataContractSurrogate Interface
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).
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
The IDataContractSurrogate type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | GetCustomDataToExport(MemberInfo, Type) | During schema export operations, inserts annotations into the schema for non-null return values. |
![]() | GetCustomDataToExport(Type, Type) | During schema export operations, inserts annotations into the schema for non-null return values. |
![]() | GetDataContractType | During serialization, deserialization, and schema import and export, returns a data contract type that substitutes the specified type. |
![]() | GetDeserializedObject | During deserialization, returns an object that is a substitute for the specified object. |
![]() | GetKnownCustomDataTypes | Sets the collection of known types to use for serialization and deserialization of the custom data objects. |
![]() | GetObjectToSerialize | During serialization, returns an object that substitutes the specified object. |
![]() | GetReferencedTypeOnImport | During schema import, returns the type referenced by the schema. |
![]() | ProcessImportedType | Processes the type that has been generated from the imported schema. |
Use the IDataContractSurrogate when using the DataContractSerializer if you need to do one of the following: substitute one type or object for another, or to dynamically generate schema variations. For a sample application, see DataContract Surrogate Sample. For more information about data contracts, see Using Data Contracts.
At run time, you can find the specific DataContractSerializer for any operation in a service by using the OperationDescription to find the DataContractSerializerOperationBehavior instance. For more information about implementing the interface to create a surrogate, see Data Contract Surrogates.
You can also use the IDataContractSurrogate to affect the import and export of XML schemas when you are using the XsdDataContractExporter and XsdDataContractImporter classes. You can do so by assigning the IDataContractSurrogate to the DataContractSurrogate property of the ExportOptions class, or to the DataContractSurrogate property of the ImportOptions class. For more information, see Schema Import and Export.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
