Postsharp 和 NLog,一般设计问题
这就是我打算做的:
- 我想编写一个面向方面的 NLog 特定 onmethodexecutionaspect 类。
- 但我仍然想确保调用代码使用通用属性类进行归因,该属性类将根据应用程序配置文件中指定的内容在内部加载 NLog 或 TraceX 等 methodexecutionaspect 的特定实现。
解决这个问题的最佳方法是什么?
我正在考虑编写一个抽象类,该类将从 postsharp 方法执行方面派生。 然后我将有另一个 dll,它将具有 NLog 特定实现...因此它将有一个类,该类将从我在通用 dll 中创建的通用方法执行方面类派生。
消费代码将仅引用我编写的通用类 dll,并且该类将加载我编写的 NLog 特定 dll(如果应用程序配置中指定了该类)。
说得通?
This is what i intend to do:
- I want to write a Aspect oriented NLog specific onmethodexecutionaspect class.
- But i still want to ensure that the calling code is attributed using a general attribute class which will internally load the NLog or TraceX etc specific implementation of methodexecutionaspect depending on what is specified in the application configuration file.
What is the best way to approach this?
I am thinking of writing a abstract class which will derive from postsharp method execution aspect.
Then i will have another dll which will have a NLog specific implementation... so it will have a class which will derive from the general method execution aspect class i have created in the general dll.
The consuming code will only reference the general class dll i have written, and that class will doa load of NLog specific dll i have written if that is what is specified in the application config.
makes sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你走在正确的道路上。
但是,请尝试改用 OnMethodBoundaryAspect。 它在运行时比 OnMethodInvocationAspect 更快。
尝试利用编译时初始化 (CompileTimeInitialize) 和运行时初始化 (RunTimeInitialize),并避免在处理程序中执行任何成本高昂的操作。
I think you are on the right track.
However, try using OnMethodBoundaryAspect instead. It is faster at runtime than OnMethodInvocationAspect.
Try to take advantage of compile-time initialization (CompileTimeInitialize) and run-time initialization (RunTimeInitialize) and avoid doing anything costly in handlers.