다음과 같은 두 개의 기본 인터페이스가 있습니다. 하나는 다른 인터페이스를 상속합니다. 나는 .. 아래와 같이 구현에ninject inherited interface
public interface IUnitOfWork { }
public interface IEventStoreUnitOfWork : IUnitOfWork { }
public class TransactionalHandler<TCommand, TCommandHandler> {
public TransactionalHandler(IUnitOfWork unitOfWork) {
// removed
}
}
public class EventStoreUnitOfWork : IEventStoreUnitOfWork { }
바인딩 ...이 작동하지 않습니다
Bind<IEventStoreUnitOfWork>().To<EventStoreUnitOfWork>();
Bind<TransactionalHandler<IDomainCommand, IDomainCommandHandler<IDomainCommand>>>()
.ToSelf()
.WithConstructorArgument("unitOfWork", Kernel.GetService(typeof(IEventStoreUnitOfWork)));
그들을 결합하고있다. 오류 :
Error activating IUnitOfWork
No matching bindings are available, and the type is not self-bindable.
Activation path:
2) Injection of dependency IUnitOfWork into parameter unitOfWork of constructor of type TransactionalHandler{CreateUserCmd, CreateUserCmdHandler}
1) Request for TransactionalHandler{CreateUserCmd, CreateUserCmdHandler}
여기 무슨 일이 일어나고 있습니까? 분명히 IUnitOfWork는 IEventStoreUnitOfWork에 상속되며 바인딩을 가지고 있습니다. 나는 이벤트를 시도했지만 같은 오류가 발생합니다 ...
Bind<TransactionalHandler<IDomainCommand, IDomainCommandHandler<IDomainCommand>>>()
.ToSelf()
.WithConstructorArgument("unitOfWork", Kernel.GetService(typeof(IEventStoreUnitOfWork)) as IUnitOfWork);
아이디어가 있습니까?
감사합니다.
내가 거기에이 명확성의 이유는 있지만, 더 큰 문제가, 내가 훌륭한 기본 바인딩을 거 야 확신을 필요로하는 경우 GitHub의에서 기본 유형을 고려한 Ninject에 포크를 가지고 인터페이스. –