XsdDataContractImporter.Import 方法

定義

將 XML 結構描述集合轉換為用來產生 CLR 程式碼的 CodeCompileUnit

多載

Import(XmlSchemaSet)

將包含在 XmlSchemaSet 的已指定 XML 結構描述集合轉換為 CodeCompileUnit

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

將包含在 XmlSchemaSet 的已指定結構描述型別集合轉換為在 CodeCompileUnit 中產生的 CLR 型別。

Import(XmlSchemaSet, XmlSchemaElement)

將已指定 XML 結構描述集合中的已指定結構描述項目轉換為 CodeCompileUnit,然後傳回 XmlQualifiedName,其中表示所指定項目的資料合約名稱。

Import(XmlSchemaSet, XmlQualifiedName)

將包含在 XmlSchemaSet 的已指定 XML 結構描述型別集合轉換為 CodeCompileUnit

Import(XmlSchemaSet)

將包含在 XmlSchemaSet 的已指定 XML 結構描述集合轉換為 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)

參數

schemas
XmlSchemaSet

XmlSchemaSet,其中包含要產生 CLR 類型的結構描述表示。

例外狀況

schemas 參數為 null

範例

下列範例會使用 CanImport 方法來測試是否能夠匯入結構描述集合。 如果 CanImport 方法傳回 true,程式碼就會叫用 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

適用於

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

將包含在 XmlSchemaSet 的已指定結構描述型別集合轉換為在 CodeCompileUnit 中產生的 CLR 型別。

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))

參數

schemas
XmlSchemaSet

XmlSchemaSet,其中包含結構描述表示。

typeNames
ICollection<XmlQualifiedName>

ICollection<T> (屬於 XmlQualifiedName),表示要匯入的結構描述類型集合。

適用於

Import(XmlSchemaSet, XmlSchemaElement)

將已指定 XML 結構描述集合中的已指定結構描述項目轉換為 CodeCompileUnit,然後傳回 XmlQualifiedName,其中表示所指定項目的資料合約名稱。

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

參數

schemas
XmlSchemaSet

XmlSchemaSet,其中包含要轉換的結構描述。

element
XmlSchemaElement

XmlSchemaElement,表示要轉換的特定結構描述項目。

傳回

XmlQualifiedName,表示指定的項目。

例外狀況

schemaselement 參數為 null

適用於

Import(XmlSchemaSet, XmlQualifiedName)

將包含在 XmlSchemaSet 的已指定 XML 結構描述型別集合轉換為 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)

參數

schemas
XmlSchemaSet

XmlSchemaSet,其中包含結構描述表示。

typeName
XmlQualifiedName

XmlQualifiedName,表示要匯入的特定結構描述類型。

例外狀況

schemastypeName 參數為 null

適用於