XsdDataContractImporter.Import 方法
定义
将一组 XML 架构转换为用于生成 CLR 代码的 CodeCompileUnit。Transforms a set of XML schemas into a CodeCompileUnit used to generate CLR code.
重载
| Import(XmlSchemaSet) |
将 XmlSchemaSet 中包含的一组指定 XML 架构转换为 CodeCompileUnit。Transforms the specified set of XML schemas contained in an XmlSchemaSet into a CodeCompileUnit. |
| Import(XmlSchemaSet, ICollection<XmlQualifiedName>) |
将 XmlSchemaSet 中包含的一组指定架构类型转换为生成到 CodeCompileUnit 中的 CLR 类型。Transforms the specified set of schema types contained in an XmlSchemaSet into CLR types generated into a CodeCompileUnit. |
| Import(XmlSchemaSet, XmlSchemaElement) |
将指定的 XML 架构集中的指定架构元素转换为 CodeCompileUnit,并返回用于表示指定元素的数据协定名称的 XmlQualifiedName。Transforms the specified schema element in the set of specified XML schemas into a CodeCompileUnit and returns an XmlQualifiedName that represents the data contract name for the specified element. |
| Import(XmlSchemaSet, XmlQualifiedName) |
将 XmlSchemaSet 中包含的指定 XML 架构类型转换为 CodeCompileUnit。Transforms the specified XML schema type contained in an XmlSchemaSet into a CodeCompileUnit. |
Import(XmlSchemaSet)
将 XmlSchemaSet 中包含的一组指定 XML 架构转换为 CodeCompileUnit。Transforms the specified set of XML schemas contained in an XmlSchemaSet into a 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 类型的架构表示。A XmlSchemaSet that contains the schema representations to generate CLR types for.
例外
schemas 参数为 null。The schemas parameter is null.
示例
下面的示例使用 CanImport 方法测试是否可以导入一组架构。The following example uses the CanImport method to test whether a set of schemas can be imported. 如果 CanImport 方法返回 true,则这些代码会调用 Import 方法。If the CanImport method returns true, the code invokes the Import method.
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>)
将 XmlSchemaSet 中包含的一组指定架构类型转换为生成到 CodeCompileUnit 中的 CLR 类型。Transforms the specified set of schema types contained in an XmlSchemaSet into CLR types generated into a CodeCompileUnit.
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,它包含架构表示。A XmlSchemaSet that contains the schema representations.
- typeNames
- ICollection<XmlQualifiedName>
表示要导入的一组架构类型的类型为 XmlQualifiedName 的 ICollection<T>。A ICollection<T> (of XmlQualifiedName) that represents the set of schema types to import.
适用于
Import(XmlSchemaSet, XmlSchemaElement)
将指定的 XML 架构集中的指定架构元素转换为 CodeCompileUnit,并返回用于表示指定元素的数据协定名称的 XmlQualifiedName。Transforms the specified schema element in the set of specified XML schemas into a CodeCompileUnit and returns an XmlQualifiedName that represents the data contract name for the specified 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,它包含要转换的架构。An XmlSchemaSet that contains the schemas to transform.
- element
- XmlSchemaElement
一个 XmlSchemaElement,它表示要转换的特定架构元素。An XmlSchemaElement that represents the specific schema element to transform.
返回
一个 XmlQualifiedName,它表示指定的元素。An XmlQualifiedName that represents the specified element.
例外
schemas 或 element 参数为 null。The schemas or element parameter is null.
适用于
Import(XmlSchemaSet, XmlQualifiedName)
将 XmlSchemaSet 中包含的指定 XML 架构类型转换为 CodeCompileUnit。Transforms the specified XML schema type contained in an XmlSchemaSet into a 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,它包含架构表示。A XmlSchemaSet that contains the schema representations.
- typeName
- XmlQualifiedName
一个 XmlQualifiedName,它表示要导入的特定架构类型。A XmlQualifiedName that represents a specific schema type to import.
例外
schemas 或 typeName 参数为 null。The schemas or typeName parameter is null.