Questions tagged [di-containers]

22 questions
15
votes
2 answers

What is wrong when Transient injected to Singleton?

There is a problem of not correctly configured DI containers named Captive Dependency by Mark Seemann. It's obviously, for example, when a "PerCall" dependency is injected into a "Singleton" one. But what about a scenario when "Transient" is…
hcp
  • 3,268
  • 6
  • 26
  • 41
13
votes
2 answers

Circular dependency - Injecting objects that are directly depended on each other

I have used Dice PHP DI container for quite a while and it seems the best in terms of simplicity of injecting dependencies. From Dice Documentation: class A { public $b; public function __construct(B $b) { $this->b = $b; …
Ilia Ross
  • 13,086
  • 11
  • 53
  • 88
4
votes
4 answers

DI-container vs. Factories

I know there are many aricles and threads on Dependency Injection, but not as much on Depenedency-Injection-Containers. I found this one by Fabien Potencier quite helpful, although it targets PHP. However the more I read about those containers I…
MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
3
votes
1 answer

Access Container in Symfony controllers

I am creating a framework on top on Symfony components. http://symfony.com/doc/2.7/create_framework/index.html I want to access the container in my controller, but I am not sure how to do it the OOP way. I am presently accessing it via global but I…
2
votes
1 answer

ASP.NET Core resolve DbContext dependency to init migrations

It's great that ASP.NET DI works out-of-the-box and recursively resolves all constructor dependencies. Though sometimes you want to be able to access DI container directly. I am wondering if there is a way? Maybe something like this: IService…
Andrei
  • 42,814
  • 35
  • 154
  • 218
2
votes
2 answers

Is it OK to resolve from a DI container outside of the composition root when dealing with plugins?

I'm building a WPF (desktop) application, utilizing dependency injection, a DI container and the Register-Resolve-Release pattern. My application also loads plugins from separate assemblies during startup, and the plugins are registered with the…
Gedde
  • 1,150
  • 10
  • 19
1
vote
1 answer

How to update asp.net core di container later on when some task is performed

I've kept settings values on di-container and settings can be changed through the management page but when i again add new settings value in service collection it's giving me old settings values. How to update di container values/service on .net…
1
vote
1 answer

DI containers and concrete values / configuration data

I have read a bit about DI and DI containers that manage the DI for you. Basically you create your classes that have dependencies, and provide a way for injection using the constructor or setter methods. You then tell your DI container, which…
Luca Fülbier
  • 2,641
  • 1
  • 26
  • 43
1
vote
1 answer

DI Container Module Registration following Dependency Inversion Principle

According to dependency inversion principle higher level module does not depend on lower level module rather they depend on abstraction. So it is a top down approach. I have a web project that has three tier. Tier 1 contain the view pages and…
1
vote
1 answer

How does Symfony injects its DI Container inside every class that extends the Controller one?

for someone it might seem stupid, anyway I am new to the Symfony world and reading the documentation I came up with a doubt: How does Symfony inject the DI Container instance inside of each Controller class which extends Controller in such a way…
tonix
  • 6,671
  • 13
  • 75
  • 136
0
votes
0 answers

How to create a View for print using prism (MVVM) without directly instantiating it via constructor

I'm working on a WPF app using prism (MVVM), and I'd like to create a View for print, which will not be displayed on GUI. My current code is shown below, but I'd like to avoid directly instantiating a View via its constructor. void ExecutePrint() { …
user4134476
  • 385
  • 4
  • 22
0
votes
0 answers

How to share steps between all feature files in specflow?ScenarioContext is not working

Hi So i am writing a feature in specflow for api testing. The feature file looks like this Scenario: make a get Request to get 200 success When the user has request for postman workspace endpoint /workspaces/ And I adds header…
amazo Tv
  • 3
  • 1
0
votes
1 answer

How to configure dependency injection "many levels down" using .NET built-in DI Container

I have a console .NET core application which uses the Microsoft.Extensions.DependencyInjection library as a dependency injection framework. I want to use this framework to inject a dependency two "levels down" without having to redundantly mention…
Dean P
  • 1,841
  • 23
  • 23
0
votes
2 answers

How to use lazy initialization together with DIContainer in Spring4D

I'm new to Spring4D and trying to understand how to combine DIContainers with lazy loaded objects. I think i get the concept of pushing all the creation of the objects back in the callstack to the root of the application and register the types and…
0
votes
0 answers

Refactoring methods to controllers to DI-Container as a service

hope ur doing well, I'm trying to minimize the repetitive code, so I created methods for each controller, all works fine, now I want to create a new controller for the method and register it in the DI container but unfortunately the Di container…
Aris Biris
  • 31
  • 3
1
2