我需要将一些全局服务(daoFactory)注入到订阅 PostUpdate 事件的 EventListenet 中。我读过可以这样做:
public class YourPostInsertListener : IPostInsertEventListener
{
private readonly IPersistentAuditor auditor;
public YourPostInsertListener(IPersistentAuditor auditor)
{
this.auditor = auditor;
}
public void OnPostInsert(PostInsertEvent @event)
但是这段代码只是抛出异常:没有为 EventListener 指定无参数构造函数。这是可以理解的行为,因为我还没有将我的服务添加到任何容器中。那么如何在 NHibernate 中指定 IoC 容器呢?