XsdDataContractImporter.CanImport 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到一個值,表示該模式是否能轉換成 CodeCompileUnit。
多載
| 名稱 | Description |
|---|---|
| CanImport(XmlSchemaSet) |
會得到一個值,表示 中 XmlSchemaSet 所包含的結構是否能轉換成 CodeCompileUnit。 |
| CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>) |
會獲得一個值,表示所包含 XmlSchemaSet 的指定型別集合是否能轉換為產生的 CodeCompileUnitCLR 型別。 |
| CanImport(XmlSchemaSet, XmlSchemaElement) |
會取得一個值,指示是否能匯入特定結構元素 XmlSchemaSet 。 |
| CanImport(XmlSchemaSet, XmlQualifiedName) |
會得到一個值,表示 中 XmlSchemaSet 所包含的結構是否能轉換成 CodeCompileUnit。 |
備註
欲了解更多可匯入型別的資訊,請參閱資料 合約序列化器支援的型別。
CanImport(XmlSchemaSet)
會得到一個值,表示 中 XmlSchemaSet 所包含的結構是否能轉換成 CodeCompileUnit。
public:
bool CanImport(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 bool CanImport(System.Xml.Schema.XmlSchemaSet schemas);
public bool CanImport(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.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
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 的指定型別集合是否能轉換為產生的 CodeCompileUnitCLR 型別。
public:
bool CanImport(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 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);
[<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.CanImport : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> bool
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
轉化的圖式。
- typeNames
- ICollection<XmlQualifiedName>
要匯入的結構型別集合。
傳回
true如果模式可以轉換;否則,。 false
- 屬性
例外狀況
schemas或typeNames參數為 null。
匯入過程中涉及的資料合約無效。
適用於
CanImport(XmlSchemaSet, XmlSchemaElement)
會取得一個值,指示是否能匯入特定結構元素 XmlSchemaSet 。
public:
bool CanImport(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 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);
[<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.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
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
- 屬性
例外狀況
schemas或element參數為 null。
匯入過程中涉及的資料合約無效。
備註
此方法檢查型別及其所參考的所有結構型別。
適用於
CanImport(XmlSchemaSet, XmlQualifiedName)
會得到一個值,表示 中 XmlSchemaSet 所包含的結構是否能轉換成 CodeCompileUnit。
public:
bool CanImport(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 bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
public bool CanImport(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.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeName As XmlQualifiedName) As Boolean
參數
- schemas
- XmlSchemaSet
圖式表示。
- typeName
- XmlQualifiedName
需要從 XmlSchemaSet.
傳回
true若結構可轉換為資料合約型態;否則,。 false
- 屬性
例外狀況
schemas或typeName參數為 null。
匯入過程中涉及的資料合約無效。
備註
欲了解更多可匯入型別的資訊,請參閱資料 合約序列化器支援的型別。