編集

次の方法で共有


XsdDataContractImporter.CanImport Method

Definition

Gets a value that indicates whether the schemas can be transformed into a CodeCompileUnit.

Overloads

CanImport(XmlSchemaSet)

Gets a value that indicates whether the schemas contained in an XmlSchemaSet can be transformed into a CodeCompileUnit.

CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)

Gets a value that indicates whether the specified set of types contained in an XmlSchemaSet can be transformed into CLR types generated into a CodeCompileUnit.

CanImport(XmlSchemaSet, XmlSchemaElement)

Gets a value that indicates whether a specific schema element contained in an XmlSchemaSet can be imported.

CanImport(XmlSchemaSet, XmlQualifiedName)

Gets a value that indicates whether the schemas contained in an XmlSchemaSet can be transformed into a CodeCompileUnit.

Remarks

For more information about types that can be imported, see Types Supported by the Data Contract Serializer.

CanImport(XmlSchemaSet)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Gets a value that indicates whether the schemas contained in an XmlSchemaSet can be transformed into a CodeCompileUnit.

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas);
member this.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
Public Function CanImport (schemas As XmlSchemaSet) As Boolean

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schemas to transform.

Returns

true if the schemas can be transformed to data contract types; otherwise, false.

Exceptions

The schemas parameter is null.

A data contract involved in the import is invalid.

Examples

The following example calls the CanImport method to determine whether the CodeCompileUnit can be generated.

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

Applies to

CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Gets a value that indicates whether the specified set of types contained in an XmlSchemaSet can be transformed into CLR types generated into a CodeCompileUnit.

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Collections::Generic::ICollection<System::Xml::XmlQualifiedName ^> ^ typeNames);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> typeNames);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeNames As ICollection(Of XmlQualifiedName)) As Boolean

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schemas to transform.

typeNames
ICollection<XmlQualifiedName>

An ICollection<T> of XmlQualifiedName that represents the set of schema types to import.

Returns

true if the schemas can be transformed; otherwise, false.

Exceptions

The schemas or typeNames parameter is null.

A data contract involved in the import is invalid.

Applies to

CanImport(XmlSchemaSet, XmlSchemaElement)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Gets a value that indicates whether a specific schema element contained in an XmlSchemaSet can be imported.

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::XmlSchemaElement ^ element);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
Public Function CanImport (schemas As XmlSchemaSet, element As XmlSchemaElement) As Boolean

Parameters

schemas
XmlSchemaSet

An XmlSchemaSet to import.

element
XmlSchemaElement

A specific XmlSchemaElement to check in the set of schemas.

Returns

true if the element can be imported; otherwise, false.

Exceptions

The schemas or element parameter is null.

A data contract involved in the import is invalid.

Remarks

This method checks the type and all schema types referenced from it.

Applies to

CanImport(XmlSchemaSet, XmlQualifiedName)

Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs
Source:
XsdDataContractImporter.cs

Gets a value that indicates whether the schemas contained in an XmlSchemaSet can be transformed into a CodeCompileUnit.

public:
 bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeName As XmlQualifiedName) As Boolean

Parameters

schemas
XmlSchemaSet

A XmlSchemaSet that contains the schema representations.

typeName
XmlQualifiedName

An XmlQualifiedName that specifies the names of the schema types that need to be imported from the XmlSchemaSet.

Returns

true if the schemas can be transformed to data contract types; otherwise, false.

Exceptions

The schemas or typeName parameter is null.

A data contract involved in the import is invalid.

Remarks

For more information about types that can be imported, see Types Supported by the Data Contract Serializer.

Applies to