ImportOptions 类

定义

表示可对 XsdDataContractImporter 设置的选项。Represents the options that can be set on an XsdDataContractImporter.

public ref class ImportOptions
public class ImportOptions
type ImportOptions = class
Public Class ImportOptions
继承
ImportOptions

示例

下面的示例创建了 ImportOptions 类的实例并设置 EnableDataBindingGenerateInternal 属性。The following example creates an instance of the ImportOptions class and sets the EnableDataBinding and GenerateInternal properties.

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

注解

XsdDataContractImporter用于使用 .NET Framework CodeDOM 从 XML 架构生成代码。The XsdDataContractImporter is used to generate code from XML schema using the .NET Framework CodeDOM. 若要从程序集生成 XML 架构,请使用 XsdDataContractExporterTo generate an XML schema from an assembly, use the XsdDataContractExporter.

有关导入和导出架构的详细信息,请参阅 架构导入和导出导入架构以生成类For more information about importing and exporting schemas, see Schema Import and Export and Importing Schema to Generate Classes.

构造函数

ImportOptions()

初始化 ImportOptions 类的新实例。Initializes a new instance of the ImportOptions class.

属性

CodeProvider

获取或设置一个 CodeDomProvider 实例,该实例提供了检查是否支持目标语言的特定选项的方法。Gets or sets a CodeDomProvider instance that provides the means to check whether particular options for a target language are supported.

DataContractSurrogate

获取或设置可用于修改在导入操作期间生成的代码的数据协定代理项。Gets or sets a data contract surrogate that can be used to modify the code generated during an import operation.

EnableDataBinding

获取或设置一个值,该值指定生成的代码中的类型是否应实现 INotifyPropertyChanged 接口。Gets or sets a value that specifies whether types in generated code should implement the INotifyPropertyChanged interface.

GenerateInternal

获取或设置一个值,该值指定生成的代码将标记为 internal 还是 public。Gets or sets a value that specifies whether generated code will be marked internal or public.

GenerateSerializable

获取或设置一个值,该值指定除了用 SerializableAttribute 属性标记生成的数据协定类以外,是否还将用 DataContractAttribute 属性进行标记。Gets or sets a value that specifies whether generated data contract classes will be marked with the SerializableAttribute attribute in addition to the DataContractAttribute attribute.

ImportXmlType

获取或设置一个值,该值确定是否将导入所有 XML 架构类型,甚至那些不符合数据协定架构的 XML 架构类型。Gets or sets a value that determines whether all XML schema types, even those that do not conform to a data contract schema, will be imported.

Namespaces

获取一个字典,它包含在导入操作期间必须使用以便生成代码的、从数据协定命名空间到 CLR 命名空间的映射。Gets a dictionary that contains the mapping of data contract namespaces to the CLR namespaces that must be used to generate code during an import operation.

ReferencedCollectionTypes

获取一个类型集合,其中的类型表示在为集合生成代码时应引用的数据协定集合,如项列表或项字典。Gets a collection of types that represents data contract collections that should be referenced when generating code for collections, such as lists or dictionaries of items.

ReferencedTypes

获取 IList<T>,其中包含生成的代码中所引用的类型。Gets a IList<T> containing types referenced in generated code.

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅