My project has an interface that takes two generic inputs and is used by multiple classes. Each of these classes inherits the interface with different concrete classes
public interface IEndpointManager<TRequest, TResponse>
{
Task<TResponse?> CreateRequestAsync(TRequest request);
}
This is one of the classes that inherits the interface.
public class PatientFinderPlusEndpoint : IEndpointManager<RequestModel<PatientFinderRequestModel>, PatientFinderResponseModel>
And then the controller, where I am injecting the service
public NewPcfPlusController([FromKeyedServices("Pcf+EndpointManager")] IEndpointManager<RequestModel<PatientFinderRequestModel>,
PatientFinderResponseModel> endpointManager)
The problem is in Startup.cs, trying to register the keyed service.
services.AddKeyedSingleton<IEndpointManager<RequestModel<PatientFinderRequestModel>, PatientFinderResponseModel>, PatientFinderPlusEndpoint>("Pcf+EndpointManager");
It errs on the parameter PatientFinderPlusEndpoint with this error
The type 'TC.Enterprise.eServicesOrchestrator.NewPath.Service.Endpoints.PatientFinderPlusEndpoint' must be convertible to 'TC.Enterprise.eServicesOrchestrator.NewPath.Service.Endpoints.IEndpointManager<TC.Enterprise.eServicesOrchestrator.NewPath.Service.Public.RequestModel<TC.Enterprise.eServicesOrchestrator.NewPath.Service.Public.Models.PatientFinder.PatientFinderRequestModel>,TC.Enterprise.eServicesOrchestrator.NewPath.Service.Public.Models.PatientFinder.PatientFinderResponseModel>' in order to use it as parameter
I'm certain its the type parameters in the interface. If I removed them then the error goes away. I thought since the class inherits the interface it would be seen as "having" the same type parameters.