Questions tagged [di-containers]

22 questions
0
votes
1 answer

Is there a better way to link related dependencies using a DI Container?

I need to get all connected SerialPorts and poll informations from them. So I wrote a Helper to get the connected SerialPorts, loop them in the Startup.ConfigureService method and add them to the DI Container: foreach (var serialPort in…
Leppin
  • 241
  • 1
  • 7
0
votes
1 answer

Resolve without Type information in unity

Unity supports resolve based on types T obj = container.Resolve("id"); that means without knowing T, I can not resolve, I am writing some extension methods for my unity container where I want to add Resolve method which would return object…
Kryptonian
  • 860
  • 3
  • 10
  • 26
0
votes
1 answer

DI container giving new instance every time?

It seems my DI container makes a new instance for ChromeDriver (IWebDriver) each time I try and get it from the container? All of this happened after refactoring my code. I suddenly needed Selenium by reference for the methods below, otherwise, it…
AAA
  • 361
  • 1
  • 5
  • 19
0
votes
1 answer

How can I map a generic abstraction to a generic implementation in Simple Injector?

I could not come of with a better title so please feel free to change it after you have read the entire question. I have the following classes: public class Foo : IFoo {} public interface IFoo { } I would like to be able to inject IFoo
MaYaN
  • 6,683
  • 12
  • 57
  • 109
0
votes
0 answers

Is it OK to pass DI Contantainer as a dependency through a long chain of classes if only last class needs it exactly?

I'm trying to implement a router in my application using DI container. So I have an Application class which loads a config and has a DI container instance. Application has Router as a service class instaniated by DI. Router has an array of Route…
0
votes
0 answers

Abstract Factory with parameter using DI Container

I have an interface called IService and derived services like IServiceA : IService, IServiceB : IService, IServiceC : IService, etc. The implementation classes of those services needs a context parameter of type MyContext, and some services will…
MaorB
  • 117
  • 2
  • 10
0
votes
1 answer

Circular Dependency With ActiveRecord Relations in Yii2

I was using ActiveRecord models by defining relationships between them in Yii2 framework. Now I am trying to use dependency injection container with my ActiveRecord models and want to inject my dependencies. But circular dependency issue is…
1
2