Share via


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)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

获取一个值,该值指示 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>)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

获取一个值,该值指示 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)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

获取一个值,该值指示 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)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

获取一个值,该值指示 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

导入操作所涉及的数据协定无效。

注解

有关可导入的类型的详细信息,请参阅 数据协定序列化程序支持的类型

适用于