PostSharp 访问原始属性标记字符串参数

发布于 2024-09-18 13:42:01 字数 289 浏览 4 评论 0原文

我有一个实现 OnMethodBoundaryAspect 的 POstSHArp 属性。标记如下:

[ExceptionLogging("RepositoryLayer")]

我想要在方面的实现中执行的操作是访问通过上面的属性标记传递的字符串。这个想法是,基于这个值,我可以(以非常基本的方式)看到在架构中调用方面的位置,在本例中是在存储库层中。

如何通过方面实现来访问该值?我在 EVentArgs 或其他任何地方都找不到它。

非常感谢

布莱恩

I have a POstSHarp attribute implementing OnMethodBoundaryAspect. The mark up is as follows:

[ExceptionLogging("RepositoryLayer")]

What I want to do within the implementation of the aspect is access the string that was passed with the attribute markup above. The idea is that based on this value I can see (in a very rudimnentary manner) where the aspect is being called in the architecture, in this case in the Repository Layer.

How do I get access to this value with the aspect implementation? I cannot find it anywhere in the EVentArgs or anywhere else.

Many thanks

Brian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や三分注定 2024-09-25 13:42:02

构造函数应该将字符串存储在切面类的实例字段中;然后您可以从 OnException 方法访问实例字段。

The constructor should store the string in an instance field of the aspect class; then you can access the instance field from the OnException method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文