ImportOptions ImportOptions ImportOptions ImportOptions Class

定義

表示可以在 XsdDataContractImporter 上設定的選項。Represents the options that can be set on an XsdDataContractImporter.

public ref class ImportOptions
public class ImportOptions
type ImportOptions = class
Public Class ImportOptions
繼承
ImportOptionsImportOptionsImportOptionsImportOptions

範例

下列範例會建立 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.NET Framework CodeDOM 的 XML 結構描述產生程式碼。The XsdDataContractImporter is used to generate code from XML schema using the .NET Framework.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() ImportOptions() ImportOptions()

初始化 ImportOptions 類別的新執行個體。Initializes a new instance of the ImportOptions class.

屬性

CodeProvider CodeProvider CodeProvider CodeProvider

取得或設定 CodeDomProvider 執行個體,這個執行個體會提供檢查是否支援目標語言之特定選項的方法。Gets or sets a CodeDomProvider instance that provides the means to check whether particular options for a target language are supported.

DataContractSurrogate DataContractSurrogate DataContractSurrogate DataContractSurrogate

取得或設定資料合約代理,這個代理可用來修改在匯入作業期間所產生的程式碼。Gets or sets a data contract surrogate that can be used to modify the code generated during an import operation.

EnableDataBinding EnableDataBinding EnableDataBinding EnableDataBinding

取得或設定值,這個值會指定在所產生程式碼中的類型是否應該實作 INotifyPropertyChanged 介面。Gets or sets a value that specifies whether types in generated code should implement the INotifyPropertyChanged interface.

GenerateInternal GenerateInternal GenerateInternal GenerateInternal

取得或設定值,這個值會指定產生的程式碼將標記為內部或公用。Gets or sets a value that specifies whether generated code will be marked internal or public.

GenerateSerializable GenerateSerializable GenerateSerializable 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 ImportXmlType ImportXmlType ImportXmlType

取得或設定值,這個值會判定是否將匯入所有的 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 Namespaces Namespaces 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 ReferencedCollectionTypes ReferencedCollectionTypes 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 ReferencedTypes ReferencedTypes ReferencedTypes

取得 IList<T>,其中包含產生之程式碼中所參考的型別。Gets a IList<T> containing types referenced in generated code.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱