Questions tagged [ioc-container]

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application.

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application. The container is responsible for managing object lifecycles (creation, initialization, destruction) and configures objects by wiring them together.

Objects managed by the container obtain references to other objects (their dependencies):

  • by explicitly asking the container, using dependency lookup methods on the container
  • automatically, because the container injects the dependencies using one or more dependency injection techniques

Frameworks that provide an ioc-container support one of these methods and often both.

The following frameworks are discussed here at Stackoverflow

For .NET:

For Java:

2163 questions
1
vote
1 answer

Unity equivalent for Ninject's Bind.ToMethod Using CQRS

I am following this CQS tuturiol https://github.com/Code-First/CQS-Sample and it uses Ninject. I currently am using Unity and trying to convert this: Bind().ToMethod(t => new QueryFactory(x =>…
Lemex
  • 3,772
  • 14
  • 53
  • 87
1
vote
1 answer

Automatic Binding Resolution with Illuminate/Container outside of Laravel

I'm trying to introduce some Illuminate components to rescue a legacy app, namely the Container, Events and Router. I can't get past a BindingResolutionException when trying to bind a concrete class to an interface. index.php
Pete McFarlane
  • 431
  • 3
  • 5
1
vote
1 answer

Laravel container binding names: uppercase vs. lowercase

I am learning how Laravel's IoC container works. I already understand most of it, but one thing makes me think. Why are some bindings types starting with lowercase and others are uppercase? I know that for uppercase ones, we can use automatic/manual…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
1
vote
1 answer

SetResolver in console application using Simple Injector

I am looking to do the equivalent of this: DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container)); But in a console application. I also have cases where I need to do this in a worker role. I don't want to have to add a…
KingOfHypocrites
  • 9,316
  • 9
  • 47
  • 69
1
vote
2 answers

Why does laravel IoC does not provisioning my class with my method?

I can't get why laravel tries to create my class itself, without using my method. I can see that IoC binding is executed (POINT 1 is shown). But singleton method is being never executed. Why? In my service provider (not deferred): /** * Register…
avasin
  • 9,186
  • 18
  • 80
  • 127
1
vote
1 answer

The benefits and correct usage of a DI Container

I'm having troubles getting the advantage of a IoC (DI) container like Ninject, Unity or whatever. I understand the concepts as follows: DI: Injecting a dependency into the class that requires it (preferably via constructor injection). I totally…
netik
  • 1,736
  • 4
  • 22
  • 45
1
vote
1 answer

Using Microsoft.NET standard library types in Unity configuration file

I am trying to register a type conversion in my config file as follows:
1
vote
1 answer

Is it good practice to inject IUnityContainer into controller class to save extra code

I am using the following in my controller IAccountRepository AcctRep; IAccountProductRepository AcctProdRep; public HomeController(IUnityContainer container) { AcctRep = container.Resolve(); AcctProdRep =…
inN0Cent
  • 363
  • 2
  • 18
1
vote
0 answers

BeanCurrentlyInCreationException: Error creating bean with name 'scrService'

I am getting following Error, for my spring ioc container definition. It basically has a Spring Quartz Scheduler Bean Definition. This is the final root cause of the error. Caused by:…
1
vote
1 answer

Caliburn Micro EventAggregator subscribe/unsubscribe multiple instances of same ViewModel

I recently found out that my Handle() method was called multiple times after a single publish... and discovered that deactivated and closed ViewModel instances were actually not disposed of and kept receiving messages ! I'm looking for a way to…
alphanoch
  • 181
  • 1
  • 8
1
vote
1 answer

How do I use GetAll with Ninject so that one failure doesn't stop the other bindings from resolving?

Some of the provided bindings for the mutli injection may fail to resolve. public List GetMyCommands() { //throws return kernel.GetAll().ToList(); } I want to still get all the successfully…
1
vote
0 answers

Unity IoC, resolve constructor dependency by it's context

I'm trying to register multiple implementation of single interface, but I would like to avoid using named type registration. Let's say I'm having following code: public interface IStorage { ... } public class DocumentStorage : IStorage { ...…
Zdeněk
  • 929
  • 1
  • 8
  • 25
1
vote
1 answer

BetterCMS won't play nice with Castle Windsor when setting an IControllerFactory

Following the standard MVC 5 tutorials for Windsor, I have created a WindsorControllerFactory with: protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) { …
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
1
vote
3 answers

How to register a class with a dependency injected constructor? (SimpleIoC)

I'm using MVVM Light in my project, but I'm not sure how to register a Viewmodel class in the ViewModelLocator class that takes a parameter in it's constructor. I've looked through the docs on IoC but don't see anything relating to registering a…
Brian Var
  • 6,029
  • 25
  • 114
  • 212
1
vote
3 answers

IoC container for Windows Phone 8.1

I'm currently working on a WP 8.1 app(runtime, not silverlight) and I want to find a IoC container. I'm using Caliburn.Micro, which is great because it's using constructor injection in the view models, but I also have a background agent which can't…