ImportOptions ImportOptions ImportOptions ImportOptions Class


Represents the options that can be set on an XsdDataContractImporter.

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


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))
        return imp.CodeCompileUnit;
        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
        Return imp.CodeCompileUnit
        Return Nothing
    End If
End Function


The XsdDataContractImporter is used to generate code from XML schema using the .NET Framework CodeDOM. To 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()

Initializes a new instance of the ImportOptions class.


CodeProvider CodeProvider CodeProvider CodeProvider

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

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

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

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

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

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()

Gets the Type of the current instance.

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

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)

Applies to

See also