我有点困惑,我有一个关于 domainevents 的片段,其中 `
public class StructureMapDomainEventHandlerFactory : IDomainEventHandlerFactory
{
public IEnumerable<IDomainEventHandler<T>> GetDomainEventHandlersFor<T>
(T domainEvent) where T : IDomainEvent
return ObjectFactory.GetAllInstances<IDomainEventHandler<T>>();
}
其中利用了 StructureMap。我刚刚开始使用 Autofac 进行 DI,这应该如何在 Autofac 中实现。因为没有静态类的概念。
一般来说,这种方法是否正确?在 Factory 类中使用 DI 有什么意义,直接在其他地方引用它不是很好吗?