I Need To Add A Generic Class With Parameter To IOC Container In Asp.net core But I Don't Know How Do It , My Class Like Bellow And have A Parameter
public class MyClass<T> : IMyclass<T>
{
string Name {get;}
public MyClass(string name)
{
Name = name;
}
}
If I Don't Have Parameter , I Can Add Generic Class To IOC Like Bellow service.AddScoped(typeof(IMyClass<>),typeof(MyClass<>));
But I Need Inject Parameter Like Name To Implementaion I Want Something Like Bellow service.AddScoped(typeof(IMyClass<>),typeof(MyClass<>("Jone Doe"));
the Important Part Is Use A Generic Class And Interface , And Have Parameter Or Prams , And When Add To IOC Idon't know What T Type Going To Create , Now How Can I Do it ?