C#C
C#4y ago
ав

ASP NET Core default DI-Container, how pass in constructor not-registered parameter? [Answered]

I want to create a Model class using a DI container, services registered in the container are passed to its constructor, and a structure is passed that becomes known only in runtime.How can I make this model class created by the container? In Ninject, I used a Factory Interface for this, how can I implement this in a standard ASP NET Core container? Once again, I want to i can create Model like that: _modelFactory.Create(data);
public class Model
{
  // ITimeService registered in container, data not registered ( creating in runtime )
  public Model(ITimeService timeService, EngineData data)
  {
    
  }
}
Was this page helpful?