【发布时间】:2015-07-23 12:58:45
【问题描述】:
所以我有一个接口和类:
public interface IMyInterface<T> where T : ISomeEntity {}
public class MyClass<T> : IMyInterface<T>
where T : ISomeEntity {}
我会有一些需要它的课程:
public class SomeClass : ISomeClass
{
public SomeClass (IMyInterface<AuditEntity> myInterface) {}
}
我做了各种各样的事情来让它注册开放的通用接口和类,但没有运气。
我只想说:
container.RegisterType(typeof(MyClass<>)).As(typeof(IMyInterface<>));
如果我必须经历并明确地做类似的事情会很烦人:
container.RegisterType<MyClass<AuditEntity>>().As<IMyInterface<AuditEntity>>();
这不应该是微不足道的吗?
【问题讨论】: