|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Delegado TypeFilter
Namespace: System.Reflection
Assembly: mscorlib (em mscorlib.dll)
[SerializableAttribute] [ComVisibleAttribute(true)] public delegate bool TypeFilter( Type m, Object filterCriteria )
Parâmetros
- m
- Tipo: System.Type
O Type o objeto para o qual o filtro é aplicado.
- filterCriteria
- Tipo: System.Object
Um objeto arbitrário, usado para filtrar a lista.
Valor de retorno
Tipo: System.BooleanImports system 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 four interfaces; two are defined in this assembly and two are defined in another assembly. Public Class MyRetailer Implements IBookRetailer, IMusicRetailer, IComparable, ICloneable ' For demonstration purposes, this method returns nothing; it just allows the code to compile. Public Function Clone() As Object Implements System.ICloneable.Clone Return Nothing End Function ' For demonstration purposes, this method returns nothing; it just allows the code to compile. Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo Return Nothing End Function ' For demonstration purposes, this method returns nothing; it just allows the code to compile. Public Sub ApplyDiscout() Implements IBookRetailer.ApplyDiscount End Sub ' For demonstration purposes, this method returns nothing; it just allows the code to compile. Public Sub Purchase() Implements IBookRetailer.Purchase End Sub ' For demonstration purposes, this method returns nothing; it just allows the code to compile. 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 interfaces() As Type = _ GetType(MyRetailer).FindInterfaces(AddressOf TypeFilter, Assembly.GetExecutingAssembly().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):") Dim t As Type 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 interface defined. 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 ' Output will vary based on the contents of the C drive. ' ' This code produces the following output. ' MyRetailer implements the following interfaces (defined in this assembly): ' IBookRetailer ' IMusicRetailer
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Função Server Core sem suporte), Windows Server 2008 R2 (Função Server Core com suporte com o SP1 ou posterior, Itanium sem suporte)
O .NET Framework não oferece suporte a todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte .Requisitos de sistema do NET Framework.