XsdDataContractExporter.CanExport メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
共通言語ランタイム (CLR) 型 (または型のセット) をエクスポートできるかどうかを示す値を取得します。
オーバーロード
| 名前 | 説明 |
|---|---|
| CanExport(ICollection<Assembly>) |
アセンブリのセットに含まれる .common language Runtime (CLR) 型のセットをエクスポートできるかどうかを示す値を取得します。 |
| CanExport(ICollection<Type>) |
ICollection<T>に含まれる .common language runtime (CLR) 型のセットをエクスポートできるかどうかを示す値を取得します。 |
| CanExport(Type) |
指定した共通言語ランタイム (CLR) 型をエクスポートできるかどうかを示す値を取得します。 |
注釈
すべての CLR 型をデータ コントラクトで使用できるわけではありません。 シリアル化できる内容の詳細については、「 データ コントラクト シリアライザーでサポートされる型」を参照してください。
CanExport(ICollection<Assembly>)
アセンブリのセットに含まれる .common language Runtime (CLR) 型のセットをエクスポートできるかどうかを示す値を取得します。
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
パラメーター
- assemblies
- ICollection<Assembly>
エクスポートする型を持つアセンブリを含むAssemblyのICollection<T>。
返品
true 型をエクスポートできる場合。それ以外の場合は false。
適用対象
CanExport(ICollection<Type>)
ICollection<T>に含まれる .common language runtime (CLR) 型のセットをエクスポートできるかどうかを示す値を取得します。
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
パラメーター
- types
- ICollection<Type>
エクスポートする指定した型を含む ICollection<T> 。
返品
true 型をエクスポートできる場合。それ以外の場合は false。
適用対象
CanExport(Type)
指定した共通言語ランタイム (CLR) 型をエクスポートできるかどうかを示す値を取得します。
public:
bool CanExport(Type ^ type);
public bool CanExport(Type type);
member this.CanExport : Type -> bool
Public Function CanExport (type As Type) As Boolean
パラメーター
返品
true 型をエクスポートできる場合。それ以外の場合は false。
例
次の例では、Export(Type) メソッドを呼び出す前に、CanExport(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