Type.FilterAttribute 필드
정의
특성에 사용되는 멤버 필터를 나타냅니다.Represents the member filter used on attributes. 이 필드는 읽기 전용입니다.This field is read-only.
public: static initonly System::Reflection::MemberFilter ^ FilterAttribute;
public static readonly System.Reflection.MemberFilter FilterAttribute;
staticval mutable FilterAttribute : System.Reflection.MemberFilter
Public Shared ReadOnly FilterAttribute As MemberFilter
필드 값
예제
다음 예제에서는 합니다 FilterAttribute
대리자를 매개 변수로 전달 합니다 FindMembers 메서드를 지정 된 멤버 및 해당 특성을 표시 합니다.The following example gets the FilterAttribute
delegate, passes it as a parameter to the FindMembers method, and displays the specified members and their attributes.
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 );
}
}
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);
}
}
}
Imports System.Reflection
Imports System.Security
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
End Class
설명
이 필드는 사용 하는 대리자에 대 한 참조를 포함 합니다 FindMembers 메서드.This field holds a reference to the delegate used by the FindMembers method. 이 대리자로 캡슐화 된 메서드는 두 매개 변수: 첫 번째는 MemberInfo 개체 이며 두 번째는 Object
합니다.The method encapsulated by this delegate takes two parameters: the first is a MemberInfo object and the second is an Object
. 메서드를 결정 하는지 여부를 MemberInfo
개체에 의해 지정 된 조건과 일치 하는 Object
합니다.The method determines whether the MemberInfo
object matches the criteria specified by the Object
. 합니다 Object
클래스의 필드 중 하나의 값을 할당할 수 있습니다 FieldAttributes를 MethodAttributes, 또는 MethodImplAttributes합니다.The Object
may be assigned the value of any one of the fields on the classes FieldAttributes, MethodAttributes, or MethodImplAttributes.
예를 들어 합니다 Object
필드의 값을 할당 FieldAttributes
Public과 같은 합니다.For example, the Object
can be assigned the value of a field from FieldAttributes
such as Public. 이런 경우는 FilterAttribute
대리자를 호출 반환 true
메서드를 나타내는 경우에는 MemberInfo
개체 메타 데이터에서 public 필드 특성으로 데코 레이트 된 합니다.In that case, when the FilterAttribute
delegate is invoked, it will return true
only if the method represented by the MemberInfo
object is decorated with the public field attribute in metadata.