語言

XsdDataContractImporter.Import 方法

定義

將一組 XML 結構轉換成 CodeCompileUnit 用於產生 CLR 程式碼的 。

多載

名稱 Description
Import(XmlSchemaSet)

將 中XmlSchemaSetCodeCompileUnit指定的 XML 結構集合轉換為 。

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

將 中 XmlSchemaSet 指定的結構型別集合轉換為產生的 CodeCompileUnitCLR 型別。

Import(XmlSchemaSet, XmlSchemaElement)

將指定 XML 架構集合中的指定結構元素轉換成 a CodeCompileUnit ,並回傳代表該元素資料合約名稱的 a XmlQualifiedName 。

Import(XmlSchemaSet, XmlQualifiedName)

將 中 XmlSchemaSet 指定的 XML 結構型態轉換成 CodeCompileUnit。

Import(XmlSchemaSet)

來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs

將 中XmlSchemaSetCodeCompileUnit指定的 XML 結構集合轉換為 。

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public void Import(System.Xml.Schema.XmlSchemaSet schemas);
public void Import(System.Xml.Schema.XmlSchemaSet schemas);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.Import : System.Xml.Schema.XmlSchemaSet -> unit
member this.Import : System.Xml.Schema.XmlSchemaSet -> unit
Public Sub Import (schemas As XmlSchemaSet)

參數

schemas
XmlSchemaSet

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

來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs

將 中 XmlSchemaSet 指定的結構型別集合轉換為產生的 CodeCompileUnitCLR 型別。

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Collections::Generic::ICollection<System::Xml::XmlQualifiedName ^> ^ typeNames);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> unit
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 A 包含結構表示。

typeNames
ICollection<XmlQualifiedName>

要匯入的結構型別集合。

屬性

適用於

Import(XmlSchemaSet, XmlSchemaElement)

來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs

將指定 XML 架構集合中的指定結構元素轉換成 a CodeCompileUnit ,並回傳代表該元素資料合約名稱的 a XmlQualifiedName 。

public:
 System::Xml::XmlQualifiedName ^ Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::XmlSchemaElement ^ element);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> System.Xml.XmlQualifiedName
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 代表指定元素的 。

屬性

例外狀況

schemas或element參數為 null。

適用於

Import(XmlSchemaSet, XmlQualifiedName)

來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs
來源:
XsdDataContractImporter.cs

將 中 XmlSchemaSet 指定的 XML 結構型態轉換成 CodeCompileUnit。

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public void Import(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
public void Import(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> unit
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> unit
Public Sub Import (schemas As XmlSchemaSet, typeName As XmlQualifiedName)

參數

schemas
XmlSchemaSet

XmlSchemaSet A 包含結構表示。

typeName
XmlQualifiedName

XmlQualifiedName A 代表要匯入的特定結構型態。

屬性

例外狀況

schemas或typeName參數為 null。

適用於