TypeConverterAttribute クラス
アセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.All)> _ Public NotInheritable Class TypeConverterAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.All)] public sealed class TypeConverterAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] public ref class TypeConverterAttribute sealed : public Attribute

変換に使用するクラスは、TypeConverter から継承する必要があります。ConverterTypeName プロパティを使用して、この属性が関連付けられているオブジェクトのデータ変換を実現するクラスの名前を取得します。
属性の詳細については、「属性の概要」と「属性を使用したメタデータの拡張」を参照してください。型コンバータの詳細については、TypeConverter 基本クラスのトピックおよび「方法 : 型コンバータを実装する」を参照してください。

MyClass に対して、MyClassConverter という名前の型コンバータを使用するように指示する例を次に示します。この例は、MyClassConverter が別の場所で実装されていることを前提にしています。コンバータ (MyClassConverter) を実装するクラスは、TypeConverter クラスから継承する必要があります。
<TypeConverter(GetType(MyClassConverter))> _ Public Class ClassA ' Insert code here. End Class 'MyClass
/** @attribute TypeConverter(MyClassConverter.class) */ public static class MyClass { // Insert code here. } //MyClass
MyClass のインスタンスを作成する例を次に示します。そのクラスの属性を取得し、MyClass で使用する型コンバータの名前を出力します。
Public Shared Function Main() As Integer ' Creates a new instance of ClassA. Dim myNewClass As New ClassA() ' Gets the attributes for the instance. Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewClass) ' Prints the name of the type converter by retrieving the ' TypeConverterAttribute from the AttributeCollection. Dim myAttribute As TypeConverterAttribute = _ CType(attributes(GetType(TypeConverterAttribute)), TypeConverterAttribute) Console.WriteLine(("The type conveter for this class is: " _ + myAttribute.ConverterTypeName)) Return 0 End Function 'Main
public static int Main() { // Creates a new instance of MyClass. MyClass myNewClass = new MyClass(); // Gets the attributes for the instance. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewClass); /* Prints the name of the type converter by retrieving the * TypeConverterAttribute from the AttributeCollection. */ TypeConverterAttribute myAttribute = (TypeConverterAttribute)attributes[typeof(TypeConverterAttribute)]; Console.WriteLine("The type conveter for this class is: " + myAttribute.ConverterTypeName); return 0; }
int main() { // Creates a new instance of MyClass. Class1::MyClass^ myNewClass = gcnew Class1::MyClass; // Gets the attributes for the instance. AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewClass ); /* Prints the name of the type converter by retrieving the * TypeConverterAttribute from the AttributeCollection. */ TypeConverterAttribute^ myAttribute = dynamic_cast<TypeConverterAttribute^>(attributes[ TypeConverterAttribute::typeid ]); Console::WriteLine( "The type converter for this class is: {0}", myAttribute->ConverterTypeName ); return 0; }
public static void main(String[] args) { // Creates a new instance of MyClass. MyClass myNewClass = new MyClass(); // Gets the attributes for the instance. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewClass); /* Prints the name of the type converter by retrieving the * TypeConverterAttribute from the AttributeCollection. */ TypeConverterAttribute myAttribute = ((TypeConverterAttribute) (attributes.get_Item( TypeConverterAttribute.class.ToType()))); Console.WriteLine(("The type conveter for this class is: " + myAttribute.get_ConverterTypeName())); } //main

System.Attribute
System.ComponentModel.TypeConverterAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TypeConverterAttribute コンストラクタ ()
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TypeConverterAttribute コンストラクタ (Type)
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TypeConverterAttribute コンストラクタ (String)
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TypeConverterAttribute コンストラクタ

名前 | 説明 |
---|---|
TypeConverterAttribute () | 既定の型コンバータである空の文字列 ("") を使用して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。 |
TypeConverterAttribute (String) | この属性が関連付けられているオブジェクトのデータ コンバータとして指定した型名を使用して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。 |
TypeConverterAttribute (Type) | この属性が関連付けられているオブジェクトのデータ コンバータとして型名を指定して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。 |

関連項目
TypeConverterAttribute クラスTypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス
TypeConverterAttribute フィールド
TypeConverterAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | ConverterTypeName | この属性が関連付けられているオブジェクトのコンバータとして使用する Type の完全修飾型名を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

TypeConverterAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の TypeConverterAttribute と等しいかどうかを示す値を返します。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

TypeConverterAttribute メンバ
この属性が関連付けられているオブジェクトのコンバータとして使用する型を指定します。このクラスは継承できません。
TypeConverterAttribute データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | ConverterTypeName | この属性が関連付けられているオブジェクトのコンバータとして使用する Type の完全修飾型名を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の TypeConverterAttribute と等しいかどうかを示す値を返します。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- TypeConverterAttributeのページへのリンク