SchemaImporterExtension 類別

定義

可以讓您在使用自動查詢工具時,自訂 Web 服務描述語言 (WSDL) 文件所產生的程式碼。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
繼承
SchemaImporterExtension
衍生

範例

請參閱 SchemaImporterExtension 技術範例See the SchemaImporterExtension Technology Sample. 請注意,此範例不包含已簽署的元件。Note that this example does not include a signed assembly. 相反地,它會示範如何搭配 SchemaImporterExtension 命令視窗使用。Instead, it demonstrates how to use the SchemaImporterExtension with a command window.

備註

每當 Web 服務 proxy 是透過 Visual Studio 中找到的 [加入 Web 參考] 對話方塊之類的工具產生,或使用 Web 服務描述語言工具 ( # A0) 時,就會發生架構匯入。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). 使用 XML 架構定義工具 ( # A0) 從特定的 XSD 檔產生程式碼時,也會發生架構匯入。Schema importation also occurs when using the XML Schema Definition Tool (Xsd.exe) to generate code from a specific XSD document.

SchemaImporterExtension類別可讓您修改使用上述任何工具時所產生的程式碼。The SchemaImporterExtension class allows you to modify the code generated when using any of these tools. 例如,您可能有一個現有的類別可處理系統上的書籍訂單,而且您擁有可提供訂單的現有 XSD 檔。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. 使用 SchemaImporterExtension 類別,您可以啟用其中一個工具來產生使用您類別的程式碼。Using the SchemaImporterExtension class, you can enable one of the tools to generate code that uses your class.

為了控制程式代碼的產生,您必須使用在命名空間中找到的類別 System.CodeDomIn order to control the generation of the code, you must use the classes found in the System.CodeDom namespace. 如需詳細資訊,請參閱 使用 codedomcodedom 快速參考For more information, see Using the CodeDOM and CodeDOM Quick Reference.

啟用 WSDL.exe 工具的步驟 (而其他工具(例如 [加入 Web 參考] 對話方塊) )會使用您的擴充功能: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. 建立類別的執行 SchemaImporterExtensionCreate an implementation of the SchemaImporterExtension class.

  2. 使用 ImportSchemaType 方法來撰寫程式碼產生器的程式碼。Use the ImportSchemaType method to write code for the code generator. 方法包含參數,可讓您檢查攔截的 XSD 型別,並建立用來產生新 CLR 程式碼的 CodeDOM 物件。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. 如有需要,請使用 ImportAnyElement 方法來處理 <xsd:any> XSD 檔中找到的元素。If required, use the ImportAnyElement method to handle <xsd:any> elements found in the XSD document.

  4. 如有需要,請使用 ImportDefaultValue 方法來檢查 XSD 檔中找到的預設值,並傳回不同的預設值。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. 將元件安裝在全域組件快取中 (GAC) 。Install the assembly in the Global Assembly Cache (GAC).

  8. 修改 machine.config 檔案以包含延伸模組。Modify the machine.config file to include the extension.

建構函式

SchemaImporterExtension()

初始化 SchemaImporterExtension 類別的新執行個體。Initializes a new instance of the SchemaImporterExtension class.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
ImportAnyElement(XmlSchemaAny, Boolean, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider)

處理結構描述中 <xsd:any> 項目的匯入。Handles the importation of the <xsd:any> elements in the schema.

ImportDefaultValue(String, String)

可讓您指定正在匯入之 XSD 型別的預設值。Allows you to specify the default value for the XSD type being imported.

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

可讓您藉由檢視匯入的結構描述以及指定其所對應的 CLR 型別,管理產生的程式碼。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)

可讓您藉由檢視匯入的結構描述以及指定其所對應的 CLR 型別,管理產生的程式碼。Allows you to manipulate the code generated by examining the imported schema and specifying the CLR type that it maps to.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於