XsdDataContractImporter.CanImport 方法

定義

取得值,這個值會指出結構描述是否能夠轉換為 CodeCompileUnit

多載

CanImport(XmlSchemaSet)

取得值,這個值會指出包含在 XmlSchemaSet 中的結構描述是否能轉換成 CodeCompileUnit

CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)

取得值,這個值會指示包含在 XmlSchemaSet 的已指定型別集合是否能夠轉換為在 CodeCompileUnit 中產生的 CLR 型別。

CanImport(XmlSchemaSet, XmlSchemaElement)

取得值,這個值會指出是否能夠匯入包含在 XmlSchemaSet 的特定結構描述項目。

CanImport(XmlSchemaSet, XmlQualifiedName)

取得值,這個值會指出包含在 XmlSchemaSet 中的結構描述是否能轉換成 CodeCompileUnit

備註

如需可匯入之型別的詳細資訊,請參閱 資料合約序列化程式支援的類型

CanImport(XmlSchemaSet)

取得值,這個值會指出包含在 XmlSchemaSet 中的結構描述是否能轉換成 CodeCompileUnit

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas);
member this.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
Public Function CanImport (schemas As XmlSchemaSet) As Boolean

參數

schemas
XmlSchemaSet

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

傳回

如果結構描述可以轉換成資料合約類型,則為 true,否則為 false

例外狀況

schemas 參數為 null

在匯入作業中的資料合約無效。

範例

下列範例會呼叫 CanImport 方法來判定是否能夠產生 CodeCompileUnit

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

適用於

CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)

取得值,這個值會指示包含在 XmlSchemaSet 的已指定型別集合是否能夠轉換為在 CodeCompileUnit 中產生的 CLR 型別。

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Collections::Generic::ICollection<System::Xml::XmlQualifiedName ^> ^ typeNames);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> typeNames);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeNames As ICollection(Of XmlQualifiedName)) As Boolean

參數

schemas
XmlSchemaSet

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

typeNames
ICollection<XmlQualifiedName>

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

傳回

如果該結構描述能夠轉換,則為 true,否則為 false

例外狀況

schemastypeNames 參數為 null

在匯入作業中的資料合約無效。

適用於

CanImport(XmlSchemaSet, XmlSchemaElement)

取得值,這個值會指出是否能夠匯入包含在 XmlSchemaSet 的特定結構描述項目。

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::XmlSchemaElement ^ element);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
Public Function CanImport (schemas As XmlSchemaSet, element As XmlSchemaElement) As Boolean

參數

schemas
XmlSchemaSet

要匯入的 XmlSchemaSet

element
XmlSchemaElement

要在結構描述集合中檢查的特定 XmlSchemaElement

傳回

如果此項目可以匯入,則為 true,否則為 false

例外狀況

schemaselement 參數為 null

在匯入作業中的資料合約無效。

備註

這個方法會檢查此類型,以及它所參考的所有結構描述類型。

適用於

CanImport(XmlSchemaSet, XmlQualifiedName)

取得值,這個值會指出包含在 XmlSchemaSet 中的結構描述是否能轉換成 CodeCompileUnit

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeName As XmlQualifiedName) As Boolean

參數

schemas
XmlSchemaSet

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

typeName
XmlQualifiedName

IListXmlQualifiedName,其中指定必須從 XmlSchemaSet 匯入的結構描述類型名稱。

傳回

如果結構描述可以轉換成資料合約類型,則為 true,否則為 false

例外狀況

schemastypeName 參數為 null

在匯入作業中的資料合約無效。

備註

如需可匯入之型別的詳細資訊,請參閱 資料合約序列化程式支援的類型

適用於