XsdDataContractImporter.Import 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将一组 XML 架构转换为 CodeCompileUnit 用于生成 CLR 代码的架构。
重载
| 名称 | 说明 |
|---|---|
| Import(XmlSchemaSet) |
将包含在一个 XmlSchemaSet 中的指定 XML 架构集转换为一个 CodeCompileUnit。 |
| Import(XmlSchemaSet, ICollection<XmlQualifiedName>) |
将包含在 CLR XmlSchemaSet 类型的指定架构类型集转换为生成的架构 CodeCompileUnit类型。 |
| Import(XmlSchemaSet, XmlSchemaElement) |
将指定 XML 架构集中的指定架构元素转换为一个 CodeCompileUnit ,并返回一个 XmlQualifiedName 表示指定元素的数据协定名称。 |
| Import(XmlSchemaSet, XmlQualifiedName) |
将包含在其中的XmlSchemaSet指定 XML 架构类型转换为 .CodeCompileUnit |
Import(XmlSchemaSet)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
将包含在一个 XmlSchemaSet 中的指定 XML 架构集转换为一个 CodeCompileUnit。
public:
void Import(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 void Import(System.Xml.Schema.XmlSchemaSet schemas);
public void Import(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.Import : System.Xml.Schema.XmlSchemaSet -> unit
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
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
将包含在 CLR XmlSchemaSet 类型的指定架构类型集转换为生成的架构 CodeCompileUnit类型。
public:
void Import(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 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);
[<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.Import : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> unit
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>
要导入的架构类型集。
- 属性
适用于
Import(XmlSchemaSet, XmlSchemaElement)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
将指定 XML 架构集中的指定架构元素转换为一个 CodeCompileUnit ,并返回一个 XmlQualifiedName 表示指定元素的数据协定名称。
public:
System::Xml::XmlQualifiedName ^ Import(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 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);
[<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.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> System.Xml.XmlQualifiedName
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 。
- 属性
例外
schemas或element参数为 null.
适用于
Import(XmlSchemaSet, XmlQualifiedName)
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
- Source:
- XsdDataContractImporter.cs
将包含在其中的XmlSchemaSet指定 XML 架构类型转换为 .CodeCompileUnit
public:
void Import(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 void Import(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
public void Import(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.Import : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> unit
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 表示要导入的特定架构类型。
- 属性
例外
schemas或typeName参数为 null.