Share via


XsdDataContractImporter.Import 方法

定义

将一组 XML 架构转换为用于生成 CLR 代码的 CodeCompileUnit

重载

Import(XmlSchemaSet)

XmlSchemaSet 中包含的一组指定 XML 架构转换为 CodeCompileUnit

Import(XmlSchemaSet, ICollection<XmlQualifiedName>)

XmlSchemaSet 中包含的一组指定架构类型转换为生成到 CodeCompileUnit 中的 CLR 类型。

Import(XmlSchemaSet, XmlSchemaElement)

将指定的 XML 架构集中的指定架构元素转换为 CodeCompileUnit,并返回用于表示指定元素的数据协定名称的 XmlQualifiedName

Import(XmlSchemaSet, XmlQualifiedName)

XmlSchemaSet 中包含的指定 XML 架构类型转换为 CodeCompileUnit

Import(XmlSchemaSet)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

XmlSchemaSet 中包含的一组指定 XML 架构转换为 CodeCompileUnit

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas);
public void Import (System.Xml.Schema.XmlSchemaSet schemas);
member this.Import : System.Xml.Schema.XmlSchemaSet -> unit
Public Sub Import (schemas As XmlSchemaSet)

参数

schemas
XmlSchemaSet

一个 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>)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

XmlSchemaSet 中包含的一组指定架构类型转换为生成到 CodeCompileUnit 中的 CLR 类型。

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);
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,它包含架构表示。

typeNames
ICollection<XmlQualifiedName>

表示要导入的一组架构类型的类型为 XmlQualifiedNameICollection<T>

适用于

Import(XmlSchemaSet, XmlSchemaElement)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

将指定的 XML 架构集中的指定架构元素转换为 CodeCompileUnit,并返回用于表示指定元素的数据协定名称的 XmlQualifiedName

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);
public System.Xml.XmlQualifiedName Import (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
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,它表示指定的元素。

例外

schemaselement 参数为 null

适用于

Import(XmlSchemaSet, XmlQualifiedName)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

XmlSchemaSet 中包含的指定 XML 架构类型转换为 CodeCompileUnit

public:
 void Import(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
public void Import (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
member this.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> unit
Public Sub Import (schemas As XmlSchemaSet, typeName As XmlQualifiedName)

参数

schemas
XmlSchemaSet

一个 XmlSchemaSet,它包含架构表示。

typeName
XmlQualifiedName

一个 XmlQualifiedName,它表示要导入的特定架构类型。

例外

schemastypeName 参数为 null

适用于