- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有以下工作单元。它的组成允许我通过我的 IOC 添加存储库,然后根据类型访问我的服务中的这些存储库——而不必在每次出现新存储库时重写工作单元。根据我所做的研究,为此使用 Activator 不足以担心性能影响。
public class DbContextUnitOfWork : IDisposable
{
public DbContextUnitOfWork(DbContext dbContext))
{
// Set DbContext
}
public void AddRepository<T>() where T : IRepository
{
// Activate T and inject DbContext
// Add to singleton list
}
public T GetRepository<T>() where T : IRepository
{
// If T exists on list return T
}
// Other methods such as save, dispose, etc.
}
我的问题是,如何配置 Windsor,以便在它完成解析 DBContextUnitOfWork 后,我可以为我需要添加的每个存储库显式调用 AddRepository 方法?
最佳答案
您可能正在添加存储库,因为稍后会需要它们。通常的方法是向 Windsor 注册存储库类型,并要求 Windsor 在那个时解析存储库,而不是使用激活器预先创建它们。
关于c# - 温莎城堡 : Inject child dependencies via method after dependency resolves,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12433380/
所以我目前有一个主 DAO 类 ITrackingToolDAO,它包含我的每个业务实体的所有服务契约(Contract)。 public partial interface ITrackingToo
您好,已将以下组件注册到 CaSTLe Windsor 中: public class CommandDispatcher : IServiceCommandDispatcher { priv
我刚刚下载了动态对象框架Clay我遇到了关于 castle project 的问题版本。 Clay 使用“城堡”v2.0 的功能,而我有一个项目已经开始引用 v2.5。不用说只是为了让事情更有趣,我是
我在将 CaSTLe Windsor Controller Factory 与新的 RenderAction 方法结合使用时遇到了问题。我收到以下错误消息: Controller “MyControl
我试图让 Windsor 为每个请求提供一个实例 ISession,它应该被注入(inject)到所有存储库中 这是我的容器设置 container.AddFacility().Register(
我一直在尝试配置 Windsor 以根据正在构建的类为服务提供不同的实现: 我读过这个 http://docs.castleproject.org/Windsor.Registering-compon
我正在查看 ProDiner 示例 MVC 项目。我将 CaSTLe Windsor 引用从 2 更新为 3。 public static void RegisterAllFromAssemblies
我们在 Windsor 容器上使用 NoTrackingReleasePolicy,因为当我们在使用后不释放我们的组件时会发生内存泄漏。现在考虑以下问题。 一些一次性组件: public class
我是一名优秀的程序员,十分优秀!