XsdDataContractExporter.CanExport Método

Definición

Obtiene un valor que indica si se puede exportar un tipo (o conjunto de tipos) Common Language Runtime (CLR).

Sobrecargas

CanExport(ICollection<Assembly>)

Obtiene un valor que indica si se puede exportar el conjunto de tipos de Common Language Runtime (CLR) incluidos en un conjunto de ensamblados.

CanExport(ICollection<Type>)

Obtiene un valor que indica si se puede exportar el conjunto tipos de Common Language Runtime (CLR) incluidos en un ICollection<T>.

CanExport(Type)

Obtiene un valor que indica si se puede exportar el tipo de Common Language Runtime (CLR) especificado.

Comentarios

No todos los tipos de CLR se pueden usar en contratos de datos. Para obtener más información sobre lo que se puede serializar, vea Tipos admitidos por el serializador de contrato de datos.

CanExport(ICollection<Assembly>)

Obtiene un valor que indica si se puede exportar el conjunto de tipos de Common Language Runtime (CLR) incluidos en un conjunto de ensamblados.

public:
 bool CanExport(System::Collections::Generic::ICollection<System::Reflection::Assembly ^> ^ assemblies);
public bool CanExport (System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies);
member this.CanExport : System.Collections.Generic.ICollection<System.Reflection.Assembly> -> bool
Public Function CanExport (assemblies As ICollection(Of Assembly)) As Boolean

Parámetros

assemblies
ICollection<Assembly>

ICollection<T> de Assembly que contiene los ensamblados con los tipos para exportar.

Devoluciones

Boolean

true si se pueden exportar los tipos; en caso contrario, false.

Se aplica a

CanExport(ICollection<Type>)

Obtiene un valor que indica si se puede exportar el conjunto tipos de Common Language Runtime (CLR) incluidos en un ICollection<T>.

public:
 bool CanExport(System::Collections::Generic::ICollection<Type ^> ^ types);
public bool CanExport (System.Collections.Generic.ICollection<Type> types);
member this.CanExport : System.Collections.Generic.ICollection<Type> -> bool
Public Function CanExport (types As ICollection(Of Type)) As Boolean

Parámetros

types
ICollection<Type>

ICollection<T> que contiene los tipos especificados para exportar.

Devoluciones

Boolean

true si se pueden exportar los tipos; en caso contrario, false.

Se aplica a

CanExport(Type)

Obtiene un valor que indica si se puede exportar el tipo de Common Language Runtime (CLR) especificado.

public:
 bool CanExport(Type ^ type);
public bool CanExport (Type type);
member this.CanExport : Type -> bool
Public Function CanExport (type As Type) As Boolean

Parámetros

type
Type

Type para exportar.

Devoluciones

Boolean

true si se puede exportar el tipo; en caso contrario, false.

Ejemplos

En el ejemplo siguiente se llama al método CanExport(Type) antes de llamar al método Export(Type).

static void ExportXSD()
{
    XsdDataContractExporter exporter = new XsdDataContractExporter();
    if (exporter.CanExport(typeof(Employee)))
    {
        exporter.Export(typeof(Employee));
        Console.WriteLine("number of schemas: {0}", exporter.Schemas.Count);
        Console.WriteLine();
        XmlSchemaSet mySchemas = exporter.Schemas;

        XmlQualifiedName XmlNameValue = exporter.GetRootElementName(typeof(Employee));
        string EmployeeNameSpace = XmlNameValue.Namespace;

        foreach (XmlSchema schema in mySchemas.Schemas(EmployeeNameSpace))
        {
            schema.Write(Console.Out);
        }
    }
}
Shared Sub ExportXSD() 

    Dim exporter As New XsdDataContractExporter()

    ' Use the ExportOptions to add the Possessions type to the 
    ' collection of KnownTypes. 
    Dim eOptions As New ExportOptions()
    eOptions.KnownTypes.Add(GetType(Possessions))        
    exporter.Options = eOptions

    If exporter.CanExport(GetType(Employee)) Then
        exporter.Export(GetType(Employee))
        Console.WriteLine("number of schemas: {0}", exporter.Schemas.Count)
        Console.WriteLine()
        Dim mySchemas As XmlSchemaSet = exporter.Schemas
        
        Dim XmlNameValue As XmlQualifiedName = _
           exporter.GetRootElementName(GetType(Employee))
        Dim EmployeeNameSpace As String = XmlNameValue.Namespace
        
        Dim schema As XmlSchema
        For Each schema In  mySchemas.Schemas(EmployeeNameSpace)
            schema.Write(Console.Out)
        Next schema
    End If

End Sub

Se aplica a