Type.FilterAttribute フィールドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Type.FilterAttribute フィールドの意味・解説 

Type.FilterAttribute フィールド

属性に適用するメンバ フィルタを表します。このフィールドは読み取り専用です。

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

Public Shared ReadOnly FilterAttribute
 As MemberFilter
Dim value As MemberFilter

value = Type.FilterAttribute
public static readonly MemberFilter FilterAttribute
public:
static initonly MemberFilter^ FilterAttribute
public static final MemberFilter FilterAttribute
public static final var
 FilterAttribute : MemberFilter
解説解説

このフィールドは、FindMembers メソッドで使用されるデリゲートへの参照を保持します。このデリゲートによってカプセル化されたメソッドは、MemberInfo オブジェクト、Object という 2 つのパラメータを受け取ります。このメソッドは、MemberInfo オブジェクトが Object に指定した基準に一致するかどうかを判断します。Object には、FieldAttributes クラス、MethodAttributes クラス、または MethodImplAttributes クラスの任意のフィールドの値を割り当てることができます。

たとえば、Object には、Public など、FieldAttributes のフィールドの値を割り当てることができます。この場合、FilterAttribute デリゲートが呼び出されると、呼び出されたデリゲートは、MemberInfo オブジェクトで表されるメソッドがメタデータでパブリック フィールド属性を使用して修飾されている場合にだけ true を返します。

使用例使用例

FilterAttribute デリゲートを取得し、これをパラメータとして FindMembers メソッドに渡して、指定されたメンバとそれらの属性を表示する例を次に示します。

Imports System
Imports System.Reflection
Imports System.Security
Imports Microsoft.VisualBasic

Public Class MyFilterAttributeSample

    Public Shared Sub Main()
        Try
            Dim myFilter As MemberFilter =
 Type.FilterAttribute
            Dim myType As Type = GetType(System.String)
            Dim myMemberInfoArray As MemberInfo()
 = myType.FindMembers(MemberTypes.Constructor Or MemberTypes.Method,
 BindingFlags.Public Or BindingFlags.Static Or BindingFlags.Instance, myFilter, MethodAttributes.SpecialName)
            Dim myMemberinfo As MemberInfo
            For Each myMemberinfo In
 myMemberInfoArray
                Console.Write(ControlChars.newline + myMemberinfo.Name)
                Console.Write(" is a " + myMemberinfo.MemberType.ToString())
            Next myMemberinfo

        Catch e As ArgumentNullException
            Console.Write("ArgumentNullException : "
 + e.Message.ToString())
        Catch e As SecurityException
            Console.Write("SecurityException : " +
 e.Message.ToString())
        Catch e As Exception
            Console.Write("Exception :" + e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'MyFilterAttributeSample
using System;
using System.Reflection;
using System.Security;

public class MyFilterAttributeSample
{
    public static void Main()
    {
        try
        {
            MemberFilter myFilter = Type.FilterAttribute;
            Type myType = typeof(System.String);
            MemberInfo[] myMemberInfoArray = myType.FindMembers(MemberTypes.Constructor
                |MemberTypes.Method, BindingFlags.Public | BindingFlags.Static |
                BindingFlags.Instance, myFilter, MethodAttributes.SpecialName);
            foreach (MemberInfo myMemberinfo in
 myMemberInfoArray) 
            { 
                Console.Write ("\n" + myMemberinfo.Name);
                Console.Write (" is a " + myMemberinfo.MemberType.ToString());
 
            }
        }
        catch(ArgumentNullException e)
        {
            Console.Write("ArgumentNullException : " + e.Message); 
        }   
        catch(SecurityException e)
        {
            Console.Write("SecurityException : " + e.Message); 
        }   
        catch(Exception e)
        {
            Console.Write("Exception :" + e.Message); 
        } 
    }    
}
using namespace System;
using namespace System::Collections;
using namespace System::Reflection;
using namespace System::Security;
int main()
{
   try
   {
      MemberFilter^ myFilter = Type::FilterAttribute;
      Type^ myType = System::String::typeid;
      array<MemberInfo^>^myMemberInfoArray = myType->FindMembers( static_cast<MemberTypes>(MemberTypes::Constructor
 | MemberTypes::Method), static_cast<BindingFlags>(BindingFlags::Public |
 BindingFlags::Static | BindingFlags::Instance), myFilter, MethodAttributes::SpecialName );
      IEnumerator^ myEnum = myMemberInfoArray->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MemberInfo^ myMemberinfo = safe_cast<MemberInfo^>(myEnum->Current);
         Console::Write( "\n {0}", myMemberinfo->Name );
         Console::Write( " is a {0}", myMemberinfo->MemberType );
      }
   }
   catch ( ArgumentNullException^ e ) 
   {
      Console::Write( "ArgumentNullException : {0}", e->Message );
   }
   catch ( SecurityException^ e ) 
   {
      Console::Write( "SecurityException : {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::Write( "Exception : {0}", e->Message );
   }

}
import System.*;
import System.Reflection.*;
import System.Security.*;

public class MyFilterAttributeSample
{
    public static void main(String[]
 args)
    {
        try {
            MemberFilter myFilter = Type.FilterAttribute;
            Type myType = System.String.class.ToType();
            MemberInfo myMemberInfoArray[] =
                myType.FindMembers(MemberTypes.Constructor | MemberTypes.Method,
                BindingFlags.Public | BindingFlags.Static
                | BindingFlags.Instance, myFilter, MethodAttributes.SpecialName);
            for (int iCtr = 0; iCtr < myMemberInfoArray.length;
 iCtr++) {
                MemberInfo myMemberinfo = myMemberInfoArray[iCtr];
                Console.Write("\n" + myMemberinfo.get_Name());
                Console.Write(" is a "
                    + myMemberinfo.get_MemberType().ToString());
            }
        }
        catch (ArgumentNullException e) {
            Console.Write("ArgumentNullException : " + e.get_Message());
        }
        catch (SecurityException e) {
            Console.Write("SecurityException : " + e.get_Message());
        }
        catch (System.Exception e) {
            Console.Write("Exception :" + e.get_Message());
        }
    } //main
} //MyFilterAttributeSample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

Type.FilterAttribute フィールドのお隣キーワード
検索ランキング

   

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



Type.FilterAttribute フィールドのページの著作権

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

©2026 GRAS Group, Inc.RSS