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

Resolve an instance of type 'B' for each instance of type 'A'

I have an interface called specification: public interface ISpecification { ... } Many implementations of this can exist within my application and I also have a processor which requires a specification: public interface IProcessor { ... } public…
Trevor Pilley
  • 16,156
  • 5
  • 44
  • 60
1
vote
1 answer

Why is calling GetInstance() in constructor suboptimal in Simple Injector?

From Using the Simple Injector in Simple Injector documentation: Note: Calling the GetInstance method in the constructor is suboptimal and should be avoided whenever possible. With ASP.NET Web Forms however, it is hard to completely avoid this.…
Gigi
  • 28,163
  • 29
  • 106
  • 188
1
vote
3 answers

inject different implementations by logged User Role

public class TheController : Controller { IThe the; public TheController( IThe the) { //when User.IsInRole("r1") The1 should be injected else r2 this.the = the; } } public class The1 : IThe{} public class The2 :…
1
vote
1 answer

Why doesn't ResolveAll get the default (not-named) registration? Why only named registrations and mappings?

If you did this: class Program { static void Main(string[] args) { var container = new UnityContainer(); container.RegisterType(); container.RegisterType
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
1
vote
1 answer

Need to have a single instance of a dependency container exist for a WCF service

The idea is to use DI container on my service contract implementation to instantiate my Business and Data classes. The reason I need to do it this way, is that I have one service contract that deals with different client requests. Each client…
Hetal
  • 65
  • 7
1
vote
1 answer

Type hinting parent::__construct() arguments in controllers

I've got a BaseController in a Laravel Framework based App with the following code: class BaseController extends Controller { public function __construct(Credentials $credentials) { $this->credentials = $credentials; } Then, all my other…
Tenzoru
  • 953
  • 1
  • 8
  • 9
1
vote
2 answers

Spring 3 constructor injection anomaly: documentation vs. reality

Facts Spring 3.2 documentation (http://docs.spring.io/spring/docs/3.2.9.RELEASE/spring-framework-reference/htmlsingle/#beans-constructor-injection): When another bean is referenced, the type is known, and matching can occur (as was the case with…
1
vote
2 answers

Windsor IHandlerSelector in RIA Services Visual Studio 2010 Beta2

I want to implement multi tenancy using Windsor and i don't know how to handle this situation: i succesfully used this technique in plain ASP.NET MVC projects and thought incorporating in a RIA Services project would be similar. So i used…
Savvas Sopiadis
  • 8,213
  • 10
  • 34
  • 53
1
vote
1 answer

instantiate ValidatorFactory with unity ioc

I am having some trouble trying to integrate FluentValidation with Unity. I have a factory class public class UnityValidatorFactory : FluentValidation.ValidatorFactoryBase { private readonly IUnityContainer _container; public…
jazza1000
  • 4,099
  • 3
  • 44
  • 65
1
vote
3 answers

Help me pick a Dependency Injection framework for .Net

Possible Duplicate: Which C#/.NET Dependency Injection frameworks are worth looking into? Yes I know this question has been asked many times, but the various frameworks keep evolving, so I would like a fresh answer on the subject. A few thoughts…
Karsten
  • 8,015
  • 8
  • 48
  • 83
1
vote
1 answer

Can StructureMap automatically generate a factory?

Does StructureMap have a feature similar to CastleWindsor's TypedFactoryFacility, where it can generate an abstract factory on the fly? Windsor example here: http://blog.ploeh.dk/2012/03/15/ImplementinganAbstractFactory/
JMarsch
  • 21,484
  • 15
  • 77
  • 125
1
vote
1 answer

Wiring objects with Dependency Injection and JSON in Objective-C Typhoon

I would like to define my objects in a JSON file, and then instantiate them using Typhoon. Is this currently possible with Typhoon? I've downloaded the code from github, and looked through the code and docs, but I don't see a way. Thanks in advance!
maximus
  • 2,417
  • 5
  • 40
  • 56
1
vote
1 answer

Castle windsor : how to not to load all components in a castle windsor xml configuration when "Resolve" is called

I would like to use "strategy pattern" with 2 Web projects, my configuration file (and only with configuration file) :
1
vote
1 answer

LifeStylePerWebRequest - how does it work?

I have a bit of an issue. I'm trying to put a "session" class into my container. I want it to stay alive, while this user is on the site. It will simply contain various information, that I will use across my controllers. I assume, but I am not…
Nicolai
  • 2,835
  • 7
  • 42
  • 52
1
vote
0 answers

StructureMap - AddAllTypesOf

With StructureMap 2.6.4.1 (no, I haven't upgraded yet; soon though), I'm trying to do something like this: Scan(scan => scan.AddAllTypesOf() .NameBy(t => { if (t.Namespace.IsNullOrWhiteSpace()) return null; …
pdalbe01
  • 828
  • 7
  • 17