AspectCore-Framework icon indicating copy to clipboard operation
AspectCore-Framework copied to clipboard

Predicates.ForService 里面获取的类不全,导致无法aop

Open asuoghs opened this issue 2 years ago • 5 comments

   config.Interceptors.AddTyped<TimerInterceptorAttribute>((AspectPredicate)(method =>
                {
                    Type declaringType = method.DeclaringType;
                    string name = declaringType.Name;
                    if (declaringType.IsGenericType)
                        name = name.Split('`')[0];
                    Console.WriteLine("Class:" + name);
                    return name.Matches("*DCache") ||
                           (declaringType.FullName ?? declaringType.Name + "." + declaringType.Name).Matches(
                               "*DCache");
                }));
                输出的class发现不全,导致无法aop

asuoghs avatar Oct 18 '23 09:10 asuoghs

麻烦补充下,没匹配到的class大概是什么样的,列举几个例子即可

liuhaoyang avatar Oct 18 '23 10:10 liuhaoyang

没匹配的都是.net core 没有注册到容器里面的

asuoghs avatar Oct 18 '23 12:10 asuoghs

那是正常的。。

liuhaoyang avatar Oct 18 '23 12:10 liuhaoyang

能兼容这种方式吗

asuoghs avatar Oct 18 '23 13:10 asuoghs

需要自己用AOP的原始API去创建代理

liuhaoyang avatar Oct 18 '23 13:10 liuhaoyang