XsdDataContractImporter.Import Metodo

Definizione

Trasforma un set di XML Schema in una classe CodeCompileUnit utilizzata per generare codice CLR.

Overload

Import(XmlSchemaSet)

Trasforma il set specificato di XML Schema contenuto in una classe XmlSchemaSet in una classe CodeCompileUnit.

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

Trasforma il set di tipi di schema specificato contenuto in una classe XmlSchemaSet in tipi CLR generati in una classe CodeCompileUnit.

Import(XmlSchemaSet, XmlSchemaElement)

Trasforma l'elemento dello schema specificato nel set di XML Schema specificati in una classe CodeCompileUnit e restituisce una classe XmlQualifiedName che rappresenta il nome del contratto dati per l'elemento specificato.

Import(XmlSchemaSet, XmlQualifiedName)

Trasforma il tipo di XML Schema specificato contenuto in una classe XmlSchemaSet in una classe CodeCompileUnit.

Import(XmlSchemaSet)

Trasforma il set specificato di XML Schema contenuto in una classe XmlSchemaSet in una classe 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)

Parametri

schemas
XmlSchemaSet

Classe XmlSchemaSet che contiene le rappresentazioni dello schema per le quali generare tipi CLR.

Eccezioni

Il valore del parametro schemas è null.

Esempio

Nell'esempio seguente viene utilizzato il metodo CanImport per verificare se è possibile importare un set di schemi. Se il metodo CanImport restituisce true, il codice richiama il metodo Import.

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

Si applica a

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

Trasforma il set di tipi di schema specificato contenuto in una classe XmlSchemaSet in tipi CLR generati in una classe 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))

Parametri

schemas
XmlSchemaSet

Classe XmlSchemaSet che contiene le rappresentazioni di schema.

typeNames
ICollection<XmlQualifiedName>

Oggetto ICollection<T> (di XmlQualifiedName) che rappresenta il set di tipi di schema da importare.

Si applica a

Import(XmlSchemaSet, XmlSchemaElement)

Trasforma l'elemento dello schema specificato nel set di XML Schema specificati in una classe CodeCompileUnit e restituisce una classe XmlQualifiedName che rappresenta il nome del contratto dati per l'elemento specificato.

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

Parametri

schemas
XmlSchemaSet

Classe XmlSchemaSet che contiene gli schemi da trasformare.

element
XmlSchemaElement

Classe XmlSchemaElement che rappresenta l'elemento dello schema specifico da trasformare.

Restituisce

Classe XmlQualifiedName che rappresenta l'elemento specificato.

Eccezioni

Il parametro schemas o il parametro element è null.

Si applica a

Import(XmlSchemaSet, XmlQualifiedName)

Trasforma il tipo di XML Schema specificato contenuto in una classe XmlSchemaSet in una classe 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)

Parametri

schemas
XmlSchemaSet

Classe XmlSchemaSet che contiene le rappresentazioni di schema.

typeName
XmlQualifiedName

Classe XmlQualifiedName che rappresenta un tipo di schema specifico da importare.

Eccezioni

Il parametro schemas o il parametro typeName è null.

Si applica a