Hi there guys,
I've been trying to solve this for the past 2 hours without any luck of even finding hints on where, how, or what to look for.
Lets say I have 2 interfaces, a public one will be exposed to those using my library, and internal one exposed to my code allowing extra functionality, and a class that implements them:
Now, I want to register those 2 interfaces for DI, but I want them to have the same object, so I did this:
However, when I try this, I'm getting a run time exception: "System.ArgumentException: 'Open generic service type 'Interfaces.IRequest`1[T]' requires registering an open generic implementation type.'"
Anyone got idea how to solve this?? or even pointers on what to look for??
I've been trying to solve this for the past 2 hours without any luck of even finding hints on where, how, or what to look for.
Lets say I have 2 interfaces, a public one will be exposed to those using my library, and internal one exposed to my code allowing extra functionality, and a class that implements them:
PHP Code
<?php
public interface IRequest<out T>
{ }
internal interface IRequestSet<T>: IRequest<T>
{ }
public class Request<T> : IRequestSet<T>
{ }
Now, I want to register those 2 interfaces for DI, but I want them to have the same object, so I did this:
PHP Code
<?php
services.AddScoped(typeof(IRequestSet<>), typeof(Request<>));
services.AddScoped(typeof(IRequest<>), provider => provider.GetService(typeof(IRequestSet<>)));
Anyone got idea how to solve this?? or even pointers on what to look for??
Have a cool signature? hit me up and I might use it.

