Bewerken

Share via


SchemaImporterExtension Class

Definition

Allows you to customize the code generated from a Web Services Description Language (WSDL) document when using automated query tools.

public ref class SchemaImporterExtension abstract
public abstract class SchemaImporterExtension
type SchemaImporterExtension = class
Public MustInherit Class SchemaImporterExtension
Inheritance
SchemaImporterExtension
Derived

Examples

See the SchemaImporterExtension Technology Sample. Note that this example does not include a signed assembly. Instead, it demonstrates how to use the SchemaImporterExtension with a command window.

Remarks

Schema importation occurs whenever a Web service proxy is produced through a tool such as the Add Web Reference dialog box found in Visual Studio, or by using the Web Services Description Language Tool (Wsdl.exe). Schema importation also occurs when using the XML Schema Definition Tool (Xsd.exe) to generate code from a specific XSD document.

The SchemaImporterExtension class allows you to modify the code generated when using any of these tools. For example, you may have an existing class that processes book orders on a system and you have an existing XSD document that supplies your orders. Using the SchemaImporterExtension class, you can enable one of the tools to generate code that uses your class.

In order to control the generation of the code, you must use the classes found in the System.CodeDom namespace. For more information, see Using the CodeDOM and CodeDOM Quick Reference.

The steps to enabling the WSDL.exe tool (which in turn is used by other tools such as the Add Web Reference dialog box) to use your extension are:

  1. Create an implementation of the SchemaImporterExtension class.

  2. Use the ImportSchemaType method to write code for the code generator. The method contains parameters that allow you to examine the intercepted XSD type and create CodeDOM objects that are used to generate the new CLR code.

  3. If required, use the ImportAnyElement method to handle <xsd:any> elements found in the XSD document.

  4. If required, use the ImportDefaultValue method to examine default values found in the XSD document and return a different default value.

  5. Compile your extension into a library.

  6. Sign the assembly.

  7. Install the assembly in the Global Assembly Cache (GAC).

  8. Modify the machine.config file to include the extension.

Constructors

SchemaImporterExtension()

Initializes a new instance of the SchemaImporterExtension class.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
ImportAnyElement(XmlSchemaAny, Boolean, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Handles the importation of the <xsd:any> elements in the schema.

ImportDefaultValue(String, String)

Allows you to specify the default value for the XSD type being imported.

ImportSchemaType(String, String, XmlSchemaObject, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Allows you to manipulate the code generated by examining the imported schema and specifying the CLR type that it maps to.

ImportSchemaType(XmlSchemaType, XmlSchemaObject, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

Allows you to manipulate the code generated by examining the imported schema and specifying the CLR type that it maps to.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to