© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
rokibox

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)
  {
    
  }
}
public class Model
{
  // ITimeService registered in container, data not registered ( creating in runtime )
  public Model(ITimeService timeService, EngineData data)
  {
    
  }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

DI in Asp.net core, abstract
C#CC# / help
2y ago
✅ ASP.NET Core DI: DbContext Not Shared in Scoped Services
C#CC# / help
8mo ago
Run ASP.NET Core app in Test Container
C#CC# / help
12mo ago