TypeFilter TypeFilter TypeFilter TypeFilter Delegate

정의

Type 개체 배열에 표시되는 클래스를 필터링합니다.Filters the classes represented in an array of Type objects.

public delegate bool TypeFilter(Type ^ m, System::Object ^ filterCriteria);
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public delegate bool TypeFilter(Type m, object filterCriteria);
type TypeFilter = delegate of Type * obj -> bool
Public Delegate Function TypeFilter(m As Type, filterCriteria As Object) As Boolean 

매개 변수

m
Type Type Type Type

필터가 적용되는 Type 개체입니다.The Type object to which the filter is applied.

filterCriteria
Object Object Object Object

목록을 필터링하는 데 사용되는 임의 개체입니다.An arbitrary object used to filter the list.

반환 값

System.Boolean

필터링된 목록에 Type을 포함하려면 true이고, 그렇지 않으면 false입니다.true to include the Type in the filtered list; otherwise false.

상속
TypeFilterTypeFilterTypeFilterTypeFilter
특성

예제

일치 하는 메서드를 정의 하는 방법을 보여 주는이 예제는 TypeFilter 대리자 프로토타입 리플렉션을 사용 하 여 일치 하는 항목의 하위 집합을 반환 하거나 필터링 할 수 있습니다.This example shows how to define a method matching the TypeFilter delegate prototype allowing you to use reflection to filter or return a subset of matching entries.

Imports System.Reflection

' This interface is defined in this assembly.
Public Interface IBookRetailer
    Sub Purchase()
    Sub ApplyDiscount()
End Interface

' This interface is also defined in this assembly.
Public Interface IMusicRetailer
    Sub Purchase()
End Interface

' This class implements three interfaces;
'    Two are defined in this assembly.
'    One is defined in another assembly.
Public Class MyRetailer
    Implements IBookRetailer, IMusicRetailer, IComparable

    ' For demonstration purposes, this method returns nothing.
    Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
        Return Nothing
    End Function

    ' For demonstration purposes only, this method does nothing.
    Public Sub ApplyDiscount() Implements IBookRetailer.ApplyDiscount
    End Sub

    ' For demonstration purposes only, this method does nothing.
    Public Sub Purchase() Implements IBookRetailer.Purchase
    End Sub

    ' For demonstration purposes only, this method does nothing.
    Public Sub Purchase1() Implements IMusicRetailer.Purchase
    End Sub
End Class

Module Module1
    Sub Main()
        ' Find the interfaces defined by the MyRetailer class. Each interface found is passed to
        ' the TypeFilter method which checks if the interface is defined in the executing assembly.
        Dim retailerType As Type = GetType(MyRetailer)
        Dim interfaces() As Type = _
            retailerType.FindInterfaces(AddressOf TypeFilter, retailerType.Assembly.GetName().ToString())

        ' Show the interfaces that are defined in this assembly that are also implemented by MyRetailer.
        Console.WriteLine("MyRetailer implements the following interfaces (defined in this assembly):")
        For Each t In interfaces
            Console.WriteLine("   {0}", t.Name)
        Next
    End Sub

    ' This method is called by the FindInterfaces method. 
    ' This method is called once per defined interface.
    Function TypeFilter(ByVal t As Type, ByVal filterCriteria As Object) As Boolean
        ' Return true if interface is defined in the same 
        ' assembly identified by the filterCriteria object.
        Return t.Assembly.GetName().ToString() = CType(filterCriteria, String)
    End Function
End Module
' The example displays the following output:
'    MyRetailer implements the following interfaces (defined in this assembly):
'      IBookRetailer
'      IMusicRetailer

설명

TypeFilter 대리자는 클래스의 목록을 필터링 하는 데 사용 됩니다.The TypeFilter delegate is used to filter a list of classes. 배열에 표시 되는 클래스를 필터링 하려면 사용할 특히 Type 개체입니다.Specifically, you use it to filter the classes represented in an array of Type objects. Type.FindInterfaces 메서드가이 대리자를 사용 하 여 반환 되는 인터페이스의 목록을 필터링 합니다.The Type.FindInterfaces method uses this delegate to filter the list of interfaces that it returns. 모든 파생된 클래스 Delegate 하 고 MulticastDelegate 생성자가 및 DynamicInvoke 메서드.Every derived class of Delegate and MulticastDelegate has a constructor and a DynamicInvoke method. 설명에 지정 된 Visual c + + 코드 예제를 보려면 Delegate합니다.See the Visual C++ code example given in the description for Delegate.

Extension Methods

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.Gets an object that represents the method represented by the specified delegate.

적용 대상

추가 정보