XsdDataContractExporter.CanExport Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene un valor que indica si se puede exportar un tipo de Common Language Runtime (CLR) (o conjunto de tipos).
Sobrecargas
| Nombre | Description |
|---|---|
| CanExport(ICollection<Assembly>) |
Obtiene un valor que indica si se puede exportar el conjunto de tipos de .Common Language Runtime (CLR) contenidos en un conjunto de ensamblados. |
| CanExport(ICollection<Type>) |
Obtiene un valor que indica si se puede exportar el conjunto de tipos de .Common Language Runtime (CLR) contenidos en .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 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>)
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
Obtiene un valor que indica si se puede exportar el conjunto de tipos de .Common Language Runtime (CLR) contenidos en un conjunto de ensamblados.
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>
ICollection<T> de Assembly que contiene los ensamblados con los tipos que se van a exportar.
Devoluciones
true si se pueden exportar los tipos; de lo contrario, false.
- Atributos
Se aplica a
CanExport(ICollection<Type>)
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
Obtiene un valor que indica si se puede exportar el conjunto de tipos de .Common Language Runtime (CLR) contenidos en .ICollection<T>
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>
que ICollection<T> contiene los tipos especificados que se van a exportar.
Devoluciones
true si se pueden exportar los tipos; de lo contrario, false.
- Atributos
Se aplica a
CanExport(Type)
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
- Source:
- XsdDataContractExporter.cs
Obtiene un valor que indica si se puede exportar el tipo de Common Language Runtime (CLR) especificado.
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
Devoluciones
true si se puede exportar el tipo; de lo contrario, false.
- Atributos
Ejemplos
En el ejemplo siguiente se llama al CanExport(Type) método antes de llamar al Export(Type) método .
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