本文整理汇总了VB.NET中System.Reflection.TypeFilter代理的典型用法代码示例。如果您正苦于以下问题:VB.NET TypeFilter代理的具体用法?VB.NET TypeFilter怎么用?VB.NET TypeFilter使用的例子?那么恭喜您, 这里精选的代理代码示例或许可以为您提供帮助。
在下文中一共展示了TypeFilter代理的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: MyRetailer
' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System.Reflection,代码行数:61,代码来源:TypeFilter 输出:
MyRetailer implements the following interfaces (defined in this assembly):
IBookRetailer
IMusicRetailer
注:本文中的System.Reflection.TypeFilter代理示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论