使用Postsharp引入构造函数

本文关键字:构造函数 Postsharp 使用 | 更新日期: 2023-09-27 18:21:24

我的方面内部有一些依赖项,我想使用IoC容器来管理这些依赖项的生命周期。

我的第一个想法是,引入一个比类型中最具体的构造函数多接受一个参数的构造函数将是解决这个问题的好方法。

然而,我似乎找不到这样做的方法,我想知道a)这是否可能,B)是否有更好的解决方案。

使用Postsharp引入构造函数

您需要使用Introduction。请参见以下教程。

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