TypeConverterAttributeとは? わかりやすく解説

TypeConverterAttribute クラス

この属性関連付けられているオブジェクトコンバータとして使用する型指定します。このクラス継承できません。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 TypeConverterAttribute
    Inherits Attribute
Dim instance As TypeConverterAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class TypeConverterAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class TypeConverterAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class TypeConverterAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class TypeConverterAttribute extends
 Attribute
解説解説
使用例使用例

MyClass に対してMyClassConverter という名前の型コンバータ使用するように指示する例を次に示します。この例は、MyClassConverter別の場所で実装されていることを前提にしています。コンバータ (MyClassConverter) を実装するクラスは、TypeConverter クラスから継承する必要があります

<TypeConverter(GetType(MyClassConverter))> _
Public Class ClassA
    ' Insert code here.
End Class 'MyClass
[TypeConverter(typeof(MyClassConverter))]
 public class MyClass {
    // Insert code here.
 }
[TypeConverter(Class1::MyClassConverter::typeid)]
ref class MyClass{
   // Insert code here.
};
/** @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.Object
   System.Attribute
    System.ComponentModel.TypeConverterAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TypeConverterAttribute コンストラクタ ()


TypeConverterAttribute コンストラクタ (Type)

この属性関連付けられているオブジェクトデータ コンバータとして型名指定して、TypeConverterAttribute クラス新しインスタンス初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Dim type As Type

Dim instance As New TypeConverterAttribute(type)
public TypeConverterAttribute (
    Type type
)
public:
TypeConverterAttribute (
    Type^ type
)
public TypeConverterAttribute (
    Type type
)
public function TypeConverterAttribute (
    type : Type
)

パラメータ

type

この属性関連付けられているオブジェクトデータ変換使用するコンバータ クラスの型を表す Type

解説解説

データ変換実現するクラスは、TypeConverter から継承する必要があります

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute コンストラクタ (String)

この属性関連付けられているオブジェクトデータ コンバータとして指定した型名使用して、TypeConverterAttribute クラス新しインスタンス初期化します。

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

Dim typeName As String

Dim instance As New TypeConverterAttribute(typeName)
public TypeConverterAttribute (
    string typeName
)
public:
TypeConverterAttribute (
    String^ typeName
)
public TypeConverterAttribute (
    String typeName
)
public function TypeConverterAttribute (
    typeName : String
)

パラメータ

typeName

この属性関連付けられているオブジェクトデータ変換使用するクラスの完全修飾名。

解説解説

データ変換実現するクラスは、TypeConverter から継承する必要があります

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute コンストラクタ

TypeConverterAttribute クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

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

関連項目

TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute フィールド


TypeConverterAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ConverterTypeName この属性関連付けられているオブジェクトコンバータとして使用する Type の完全修型名取得します
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
参照参照

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute メソッド


パブリック メソッドパブリック メソッド

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

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute メンバ

この属性関連付けられているオブジェクトコンバータとして使用する型指定します。このクラス継承できません。

TypeConverterAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド 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 から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TypeConverterAttribute」の関連用語

TypeConverterAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TypeConverterAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS