看起来你有一个循环引用-
FirstVendorAccount
需要知道
FirstVendor
使其中一个类成为具有泛型类型的“支配”类,那么另一个可以只返回基接口。
public interface IVendor
{
string Name { get; set; }
}
public interface IVendor<TC> : IVendor where TC : IAccount
{
IEnumerable<TC> Accounts { get; set; }
}
public interface IAccount
{
string Name { get; set; }
}
// no longer needs IVendor<TC> before it can be compiled
public interface IAccount<TC> : IAccount where TC : IExecutionPeriod
{
IVendor Vendor{ get; set; }
IEnumerable<TC> ExecutionPeriods { get; set; }
}
值得一看的是,您是否真的需要所有的泛型类型——您最好使用非泛型底层接口,因为这些接口将更容易编写代码。