我正在尝试理解,为什么当我传递给基础构造函数的接口实现了正确的接口时,会出现此异常。
示例接口:
示例接口:
public interface IAppService<T,TSpecification> where T: AppEntity
where TSpecification: IBaseSpecification<T>
{
......
}
//I tried setting both the ISomeEntitySpecification and SomeEntitySpecification implementation
public interface ISomeService: IAppService<SomeEntity,ISomeEntitySpecification>
{
.....
}
public interface ISomeEntitySpecification: IBaseSpecification<SomeEntity>
{
.....
}
public interface IBaseSpecification<T> where T: class
{
....
}
示例实现:
public class SomeEntitySpecification: BaseSpecification<SomeEntity>, ISomeEntitySpecification
{
...
}
public class SomeService: AppService<SomeEntity,SomeEntitySpecification>, ISomeService
{
....
}
用例:
public BaseAppController<T>: Controller where T: AppEntity
{
public BaseAppController(IAppService<T, IBaseSpecification<T>>)
{
.....
}
}
//This is where i get the error
public SomeController: BaseAppController<SomeEntity>
{
public SomeController(ISomeService someService):base(someService)
{
.....
}
}
Visual Studio的IDE告诉我,someService
无法分配给BaseAppController
的构造函数参数。我不确定为什么。
IBaseSpecification<T>
的签名吗? - Evan L