XsdDataContractExporter.CanExport Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает значение, указывающее, можно ли экспортировать тип среды CLR (или набор типов).
Перегрузки
| Имя | Описание |
|---|---|
| CanExport(ICollection<Assembly>) |
Возвращает значение, указывающее, можно ли экспортировать набор типов среды CLR, содержащихся в наборе сборок. |
| CanExport(ICollection<Type>) |
Возвращает значение, указывающее, можно ли экспортировать набор типов среды CLR, содержащихся в объекте ICollection<T> . |
| CanExport(Type) |
Возвращает значение, указывающее, можно ли экспортировать указанный тип среды CLR. |
Комментарии
Не все типы СРЕДЫ CLR можно использовать в контрактах данных. Дополнительные сведения о том, что можно сериализовать, см. в разделе "Типы, поддерживаемые сериализатором контракта данных".
CanExport(ICollection<Assembly>)
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
Возвращает значение, указывающее, можно ли экспортировать набор типов среды CLR, содержащихся в наборе сборок.
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
Параметры
- assemblies
- ICollection<Assembly>
ICollection<T> Содержит Assembly сборки с типами для экспорта.
Возвращаемое значение
- Атрибуты
Применяется к
CanExport(ICollection<Type>)
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
Возвращает значение, указывающее, можно ли экспортировать набор типов среды CLR, содержащихся в объекте 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
Параметры
- types
- ICollection<Type>
Объект, ICollection<T> содержащий указанные типы для экспорта.
Возвращаемое значение
- Атрибуты
Применяется к
CanExport(Type)
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
- Исходный код:
- XsdDataContractExporter.cs
Возвращает значение, указывающее, можно ли экспортировать указанный тип среды CLR.
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
Параметры
Возвращаемое значение
true Значение , если тип можно экспортировать; falseв противном случае .
- Атрибуты
Примеры
В следующем примере метод вызывается CanExport(Type) перед вызовом 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