Export (0) Print
Expand All

SchemaImporterExtension.ImportSchemaType Method (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.

Namespace:  System.Xml.Serialization.Advanced
Assembly:  System.Xml (in System.Xml.dll)

abstract ImportSchemaType : 
        name:string * 
        ns:string * 
        context:XmlSchemaObject * 
        schemas:XmlSchemas * 
        importer:XmlSchemaImporter * 
        compileUnit:CodeCompileUnit * 
        mainNamespace:CodeNamespace * 
        options:CodeGenerationOptions * 
        codeProvider:CodeDomProvider -> string  
override ImportSchemaType : 
        name:string * 
        ns:string * 
        context:XmlSchemaObject * 
        schemas:XmlSchemas * 
        importer:XmlSchemaImporter * 
        compileUnit:CodeCompileUnit * 
        mainNamespace:CodeNamespace * 
        options:CodeGenerationOptions * 
        codeProvider:CodeDomProvider -> string

Parameters

name
Type: System.String

The name of the element.

ns
Type: System.String

The namespace of the element.

context
Type: System.Xml.Schema.XmlSchemaObject

An XmlSchemaObject that represents schema information, such as the line number of the XML element.

schemas
Type: System.Xml.Serialization.XmlSchemas

An XmlSchemas that contains the collection of schemas in the document.

importer
Type: System.Xml.Serialization.XmlSchemaImporter

The XmlSchemaImporter that is the importer being used.

compileUnit
Type: System.CodeDom.CodeCompileUnit

A CodeCompileUnit to which you can add CodeDOM structures to generate alternative code for the XSD.

mainNamespace
Type: System.CodeDom.CodeNamespace

A CodeNamespace that represents the current namespace for the element.

options
Type: System.Xml.Serialization.CodeGenerationOptions

A CodeGenerationOptions for the setting options on the code compiler.

codeProvider
Type: System.CodeDom.Compiler.CodeDomProvider

A CodeDomProvider that is used to generate the new code.

Return Value

Type: System.String
The name of the CLR type that this maps to.

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 example below shows a simple implementation of the ImportSchemaType(String, String, XmlSchemaObject, XmlSchemas, XmlSchemaImporter, CodeCompileUnit, CodeNamespace, CodeGenerationOptions, CodeDomProvider) method. The code checks the namespace and name. When the right values are found, it adds the name of a custom assembly ("Order.dll") that must be referenced in the generated code. It then adds a new namespace ("Microsoft.Samples") that is generated in the code.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft