Type.FilterAttribute Field
Represents the member filter used on attributes. This field is read-only.
Assembly: mscorlib (in mscorlib.dll)
Field Value
Type: System.Reflection.MemberFilterThis field holds a reference to the delegate used by the FindMembers method. The method encapsulated by this delegate takes two parameters: the first is a MemberInfo object and the second is an Object. The method determines whether the MemberInfo object matches the criteria specified by the Object. The Object may be assigned the value of any one of the fields on the classes FieldAttributes, MethodAttributes, or MethodImplAttributes.
For example, the Object can be assigned the value of a field from FieldAttributes such as 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.
The following example gets the FilterAttribute delegate, passes it as a parameter to the FindMembers method, and displays the specified members and their attributes.
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
Available since 1.1