Modifier

Partager via


XsdDataContractImporter.Import Method

Definition

Transforms a set of XML schemas into a CodeCompileUnit used to generate CLR code.

Overloads

Import(XmlSchemaSet)

Transforms the specified set of XML schemas contained in an XmlSchemaSet into a CodeCompileUnit.

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

Transforms the specified set of schema types contained in an XmlSchemaSet into CLR types generated into a CodeCompileUnit.

Import(XmlSchemaSet, XmlSchemaElement)

Transforms the specified schema element in the set of specified XML schemas into a CodeCompileUnit and returns an XmlQualifiedName that represents the data contract name for the specified element.

Import(XmlSchemaSet, XmlQualifiedName)

Transforms the specified XML schema type contained in an XmlSchemaSet into a CodeCompileUnit.

Import(XmlSchemaSet)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Transforms the specified set of XML schemas contained in an XmlSchemaSet into a CodeCompileUnit.

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas);
public void Import (System.Xml.Schema.XmlSchemaSet schemas);
member this.Import : System.Xml.Schema.XmlSchemaSet -> unit
Public Sub Import (schemas As XmlSchemaSet)

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schema representations to generate CLR types for.

Exceptions

The schemas parameter is null.

Examples

The following example uses the CanImport method to test whether a set of schemas can be imported. If the CanImport method returns true, the code invokes the Import method.

static CodeCompileUnit Import(XmlSchemaSet schemas)
{

    XsdDataContractImporter imp = new XsdDataContractImporter();

    // The EnableDataBinding option adds a RaisePropertyChanged method to
    // the generated code. The GenerateInternal causes code access to be
    // set to internal.
    ImportOptions iOptions = new ImportOptions();
    iOptions.EnableDataBinding = true;
    iOptions.GenerateInternal = true;
    imp.Options = iOptions;

    if (imp.CanImport(schemas))
    {
        imp.Import(schemas);
        return imp.CodeCompileUnit;
    }
    else
    {
        return null;
    }
}
Shared Function Import(ByVal schemas As XmlSchemaSet) As CodeCompileUnit 

    Dim imp As New XsdDataContractImporter()
   ' The EnableDataBinding option adds a RaisePropertyChanged method to
   ' the generated code. The GenerateInternal causes code access to be
   ' set to internal.
   Dim iOptions As New ImportOptions()
   iOptions.EnableDataBinding = true
   iOptions.GenerateInternal = true
   imp.Options = IOptions

    If imp.CanImport(schemas) Then
        imp.Import(schemas)
        Return imp.CodeCompileUnit
    Else
        Return Nothing
    End If
End Function

Applies to

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Transforms the specified set of schema types contained in an XmlSchemaSet into CLR types generated into a CodeCompileUnit.

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Collections::Generic::ICollection<System::Xml::XmlQualifiedName ^> ^ typeNames);
public void Import (System.Xml.Schema.XmlSchemaSet schemas, System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> typeNames);
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> unit
Public Sub Import (schemas As XmlSchemaSet, typeNames As ICollection(Of XmlQualifiedName))

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schema representations.

typeNames
ICollection<XmlQualifiedName>

A ICollection<T> (of XmlQualifiedName) that represents the set of schema types to import.

Applies to

Import(XmlSchemaSet, XmlSchemaElement)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Transforms the specified schema element in the set of specified XML schemas into a CodeCompileUnit and returns an XmlQualifiedName that represents the data contract name for the specified element.

public:
 System::Xml::XmlQualifiedName ^ Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::XmlSchemaElement ^ element);
public System.Xml.XmlQualifiedName? Import (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
public System.Xml.XmlQualifiedName Import (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> System.Xml.XmlQualifiedName
Public Function Import (schemas As XmlSchemaSet, element As XmlSchemaElement) As XmlQualifiedName

Parameters

schemas
XmlSchemaSet

An XmlSchemaSet that contains the schemas to transform.

element
XmlSchemaElement

An XmlSchemaElement that represents the specific schema element to transform.

Returns

An XmlQualifiedName that represents the specified element.

Exceptions

The schemas or element parameter is null.

Applies to

Import(XmlSchemaSet, XmlQualifiedName)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Transforms the specified XML schema type contained in an XmlSchemaSet into a CodeCompileUnit.

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
public void Import (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> unit
Public Sub Import (schemas As XmlSchemaSet, typeName As XmlQualifiedName)

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schema representations.

typeName
XmlQualifiedName

A XmlQualifiedName that represents a specific schema type to import.

Exceptions

The schemas or typeName parameter is null.

Applies to