XsdDataContractImporter.CanImport 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示架构是否可以转换为一个 CodeCompileUnit。
重载
| 名称 | 说明 |
|---|---|
| CanImport(XmlSchemaSet) |
获取一个值,该值指示是否可以将包含 XmlSchemaSet 的架构转换为一个 CodeCompileUnit。 |
| CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>) |
获取一个值,该值指示是否可以将包含在一 XmlSchemaSet 组中指定的类型转换为生成的 CodeCompileUnitCLR 类型。 |
| CanImport(XmlSchemaSet, XmlSchemaElement) |
获取一个值,该值指示是否可以导入包含 XmlSchemaSet 的特定架构元素。 |
| CanImport(XmlSchemaSet, XmlQualifiedName) |
获取一个值,该值指示是否可以将包含 XmlSchemaSet 的架构转换为一个 CodeCompileUnit。 |
注解
有关可导入的类型的详细信息,请参阅 数据协定序列化程序支持的类型。
CanImport(XmlSchemaSet)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
获取一个值,该值指示是否可以将包含 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
包含要转换的架构的 A 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>)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
获取一个值,该值指示是否可以将包含在一 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)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
获取一个值,该值指示是否可以导入包含 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)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
获取一个值,该值指示是否可以将包含 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.
导入中涉及的数据协定无效。
注解
有关可导入的类型的详细信息,请参阅 数据协定序列化程序支持的类型。