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

How to pass a function to another class using IoC

I am trying to implement inversion of control (IoC) in order to develop a plug-in based application, which needs to be able to pass data (e.g. strings) back to my main EXE when something happens. To achieve this, I am passing an Action to the DLL…
berti
  • 127
  • 1
  • 15
1
vote
1 answer

How can I correctly use StructureMap (or any other IoC container) on a multi layered solution?

I have a 3 layer solution with the following structure: UI -> BLL <- DAL The UI is an ASP.NET MVC application. Each controller requires BLL components on its constructor. And each BLL component requires DAL components on its constructor. In the past…
1
vote
1 answer

Castle Windsor Installers with constructor parameters

I have the following class. public class NHibernateInstaller : IWindsorInstaller { private string _overrideConnectionstring; private IPersistenceConfigurer _persistenceConfigurer; private static IPersistenceConfigurer…
Andrew
  • 5,215
  • 1
  • 23
  • 42
1
vote
3 answers

Injection of multiple parameters of the same type in Ninject

Lets say we have a class X like this: class X { X(Z a, Z b) { } } And the Z class would have a Y dependency: class Z { Z(Y c) { } } What's the proper way to bind these classes such that two instances of Z, each of them with a different…
Jassel
  • 63
  • 7
1
vote
1 answer

Applying IoC design in library with multiple entry points

I'm creating NuGet package which will allow its consumers to easily send/receive messages from Azure topics/queues (plus some specific for my needs additional logic). Package internal structure is pretty complicated with a lot of dependencies and is…
1
vote
2 answers

Mocking vs IoC container in unit testing

TL;DR - I mixed up "Integration Tests" with "Unit Tests". I'm confused about Unit Testing and IoC containers... :( I've read this article about how you should not use IoC containers in Unit Testing. This seems to be an opinion of many people on SO…
Mirek
  • 4,013
  • 2
  • 32
  • 47
1
vote
1 answer

dryIOC container implementation for webapi 2 project c#

I'm really new to VS C# and coming from JAVA(Spring) background I'v embark my self in doing a POC with Webapi 2 and VS2013. So now I'm stuck at the DI container creation so I'm going to use dryIoc but I'm not sure exactly how to create one? even…
yokodev
  • 1,266
  • 2
  • 14
  • 28
1
vote
1 answer

StructureMap with Interception and Castle.DynamicProxy

I'm trying to get StructureMap to put a Castle.DynamicProxy around some of the objects it creates. I have used the EnrichWith-feature earlier, but I think RegisterInterception would suit me better in this case, since I use scanning. The problem is…
gautema
  • 634
  • 5
  • 16
1
vote
1 answer

Laravel 4: Target Interface is not instantiable

I've been comparing my code to this question and many other guides online but with little success. Everything works fine until I try to inject the the interface in my controller. When I do inject it, I get the Target Interface is not instantiable…
Christophe
  • 146
  • 6
  • 14
1
vote
1 answer

why use ioc container in php applications?

I already know what is IOC and also I have done some PHP projects with Laravel (4.3) framework which is IOC based. also I know ZEND (1.12) and have done some projects with it. I know how ZEND MVC system works. I know what are ZEND plugins (front…
1
vote
0 answers

Resolving a singleton object out of the IoC container

I'm running into some trouble while using the IoC container in Laravel 4.2 I have 2 classes: BlockFactory and Block. They are meant to display blocks of content (much like joomla modules) where a single Block represents a block of content and the…
Nick
  • 2,862
  • 5
  • 34
  • 68
1
vote
1 answer

Stop application on System.ComponentModel.Composition Warning from MEF

When starting the application, which is bootstrapped with the MefBootstrapper from PRISM, I sometimes get a System.ComponentModel.Composition Warning. This is during the composition when there are problems loading some part. However the application…
Richard Houltz
  • 1,962
  • 1
  • 18
  • 24
1
vote
1 answer

How to inject a changing dependency

I'm new to dependency injection, I'm wondering how you would handle the following scenario. We have something like the following: public class DatabaseContext { public string ConnectionString {get;} } public interface IDataAccess { string…
Kyle
  • 547
  • 1
  • 3
  • 7
1
vote
1 answer

Best practices to resolve dependecies between components of the same level of the application

This is a very simple question. I am using a IoC Container to register key depedencies at root level. For the rest of the dependencies, I use constructor injection.. What are the best practices to resolve dependecies between services of the same…
Minduca
  • 1,121
  • 9
  • 19
1
vote
1 answer

Register type with default value in parameter

I have type with default value in constructor : public Receiver(ISerializer serializer, string key, IInterceptor interceptor = default(IInterceptor)) I try to register this type : containerBuilder .RegisterType() …
Shira
  • 63
  • 1
  • 9