Прочетете на английски Редактиране

Споделяне чрез


XsdDataContractExporter.CanExport Method

Definition

Gets a value that indicates whether a common language runtime (CLR) type (or set of types) can be exported.

Overloads

CanExport(ICollection<Assembly>)

Gets a value that indicates whether the set of .common language runtime (CLR) types contained in a set of assemblies can be exported.

CanExport(ICollection<Type>)

Gets a value that indicates whether the set of .common language runtime (CLR) types contained in a ICollection<T> can be exported.

CanExport(Type)

Gets a value that indicates whether the specified common language runtime (CLR) type can be exported.

Remarks

Not all CLR types can be used in data contracts. For more information about what can be serialized, see Types Supported by the Data Contract Serializer.

CanExport(ICollection<Assembly>)

Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs

Gets a value that indicates whether the set of .common language runtime (CLR) types contained in a set of assemblies can be exported.

C#
public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies);

Parameters

assemblies
ICollection<Assembly>

A ICollection<T> of Assembly that contains the assemblies with the types to export.

Returns

true if the types can be exported; otherwise, false.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

CanExport(ICollection<Type>)

Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs

Gets a value that indicates whether the set of .common language runtime (CLR) types contained in a ICollection<T> can be exported.

C#
public bool CanExport(System.Collections.Generic.ICollection<Type> types);

Parameters

types
ICollection<Type>

A ICollection<T> that contains the specified types to export.

Returns

true if the types can be exported; otherwise, false.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

CanExport(Type)

Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs
Source:
XsdDataContractExporter.cs

Gets a value that indicates whether the specified common language runtime (CLR) type can be exported.

C#
public bool CanExport(Type type);

Parameters

type
Type

The Type to export.

Returns

true if the type can be exported; otherwise, false.

Examples

The following example calls the CanExport(Type) method before calling the Export(Type) method.

C#
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);
        }
    }
}

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1