Вы можете устранить повторяемость T
, выполнив следующее:
public static class Foo<T> where T : IComparable<T>
{
public interface IService { }
public class CommonController<S> where S : IService, new() { }
public class CustomerService : IService { }
public class CustomerController : CommonController<CustomerService> { }
}
Но если вам нужно определить CustomerService
и CustomerController
вне Foo<T>
, тогда вы в основном вернетесь к квадрат один.
public static class Foo<T> where T : IComparable<T>
{
public interface IService { }
public class CommonController<S> where S : IService, new() { }
}
public class CustomerService : Foo<int>.IService { }
public class CustomerController : Foo<int>.CommonController<CustomerService> { }
Таким образом, ответ, в основном, нет.