使用Postsharp引入构造函数
我的方面有一些依赖项,我想使用 IoC 容器来管理这些依赖项的生命周期。
我的第一个想法是,引入一个比类型中最具体的构造函数多一个参数的构造函数将是解决此问题的好方法。
然而,我似乎找不到一种方法来做到这一点,我想知道 A)这是否可能,以及 B)是否有更好的解决方案来解决这个问题。
I have some dependencies inside of my aspects, and I'd like use an IoC container to manage the lifecycle of these dependencies.
My first thought is that introducing a constructor which takes one more argument than the most specific constructor in the type would be a good way to solve this.
I can't seem to find a way to do this however, and I was wondering if A) this is possible, and B) Whether there are better solutions to this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用简介。请参阅以下教程。
http://www.sharpcrafters.com/blog/post/PostSharp-Principals-Day-14-e28093-Introducing-members-and-interfaces-Part-1.aspx
http://www.sharpcrafters.com/blog/post/PostSharp-Principals-Day-15-e28093-Introducing-members-and-interfaces-Part-2.aspx
You need to use Introduction. See the following tutorials.
http://www.sharpcrafters.com/blog/post/PostSharp-Principals-Day-14-e28093-Introducing-members-and-interfaces-Part-1.aspx
http://www.sharpcrafters.com/blog/post/PostSharp-Principals-Day-15-e28093-Introducing-members-and-interfaces-Part-2.aspx