Reflection 如何通过反射找到标记有postsharp aspect的类
我尝试了一些使用postsharp的方法 我的一个自定义特性的定义如下所示:Reflection 如何通过反射找到标记有postsharp aspect的类,reflection,postsharp,Reflection,Postsharp,我尝试了一些使用postsharp的方法 我的一个自定义特性的定义如下所示: <Serializable> _ <MulticastAttributeUsage(PersistMetaData:=True)> _ Public Class StringChecker Inherits LocationInterceptionAspect Public Overrides Sub OnGetValue(ByVal args As LocationInter
<Serializable> _
<MulticastAttributeUsage(PersistMetaData:=True)> _
Public Class StringChecker
Inherits LocationInterceptionAspect
Public Overrides Sub OnGetValue(ByVal args As LocationInterceptionArgs)
MyBase.OnGetValue(args)
..... ..... .....
当我使用一个普通属性来测试建议时,查询会传递所需的类型。
希望有人能给我一个提示我该做什么
编辑:看起来自定义属性只能在类propertys中找到
问候,,
Markus有两种方法:
你好,盖尔,谢谢你的快速回复。在您的ReflectionSearch文档中,我发现了一个仅在编译时可用的提示-是这样吗?
Dim targetClasses As IEnumerable(Of Type) = From asm In AppDomain.CurrentDomain.GetAssemblies().Where(Function(A) A.FullName.Contains("MyNameSpace")) _
.SelectMany(Function(A) A.GetTypes()) _
.Where(Function(T) T.IsDefined(GetType(StringChecker), True))