XsdDataContractExporter.CanExport Método

Definição

Recebe um valor que indica se um tipo de execução em linguagem comum (CLR) (ou um conjunto de tipos) pode ser exportado.

Sobrecargas

Name Description
CanExport(ICollection<Assembly>)

Obtém um valor que indica se o conjunto de tipos de runtime da linguagem .common (CLR) contidos num conjunto de assemblies pode ser exportado.

CanExport(ICollection<Type>)

Obtém um valor que indica se o conjunto de tipos de runtime de linguagem .common (CLR) contidos em um ICollection<T> pode ser exportado.

CanExport(Type)

Recebe um valor que indica se o tipo especificado de tempo de execução de linguagem comum (CLR) pode ser exportado.

Observações

Nem todos os tipos de CLR podem ser usados em contratos de dados. Para mais informações sobre o que pode ser serializado, veja Tipos Suportados pelo Data Contract Serializer.

CanExport(ICollection<Assembly>)

Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs

Obtém um valor que indica se o conjunto de tipos de runtime da linguagem .common (CLR) contidos num conjunto de assemblies pode ser exportado.

public:
 bool CanExport(System::Collections::Generic::ICollection<System::Reflection::Assembly ^> ^ assemblies);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies);
public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanExport : System.Collections.Generic.ICollection<System.Reflection.Assembly> -> bool
member this.CanExport : System.Collections.Generic.ICollection<System.Reflection.Assembly> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
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>

Um ICollection<T> de Assembly que contém os assemblies com os tipos a exportar.

Devoluções

true se os tipos puderem ser exportados; caso contrário, false.

Atributos

Aplica-se a

CanExport(ICollection<Type>)

Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs

Obtém um valor que indica se o conjunto de tipos de runtime de linguagem .common (CLR) contidos em um ICollection<T> pode ser exportado.

public:
 bool CanExport(System::Collections::Generic::ICollection<Type ^> ^ types);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(System.Collections.Generic.ICollection<Type> types);
public bool CanExport(System.Collections.Generic.ICollection<Type> types);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(System.Collections.Generic.ICollection<Type> types);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanExport : System.Collections.Generic.ICollection<Type> -> bool
member this.CanExport : System.Collections.Generic.ICollection<Type> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanExport : System.Collections.Generic.ICollection<Type> -> bool
Public Function CanExport (types As ICollection(Of Type)) As Boolean

Parâmetros

types
ICollection<Type>

A ICollection<T> que contém os tipos especificados para exportar.

Devoluções

true se os tipos puderem ser exportados; caso contrário, false.

Atributos

Aplica-se a

CanExport(Type)

Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs
Origem:
XsdDataContractExporter.cs

Recebe um valor que indica se o tipo especificado de tempo de execução de linguagem comum (CLR) pode ser exportado.

public:
 bool CanExport(Type ^ type);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(Type type);
public bool CanExport(Type type);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanExport(Type type);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanExport : Type -> bool
member this.CanExport : Type -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanExport : Type -> bool
Public Function CanExport (type As Type) As Boolean

Parâmetros

type
Type

O Type para exportar.

Devoluções

true se o tipo puder ser exportado; caso contrário, false.

Atributos

Exemplos

O exemplo seguinte chama o CanExport(Type) método antes de o Export(Type) chamar.

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

Aplica-se a