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
3 answers

Should one use DI on POCO classes when doing DDD?

Say I have a nice domain model, using (constructor) DI where needed. Now I want to be able to persist this model, so I start adding infrastructure(Entity Framework) to do this. What happens now is that the persistence framework should be able to…
1
vote
1 answer

Simple Injector: Automatic constructor injection recursion

I am trying to understand how automatic constructor injection is done in SimpleInjector.NET. My working source code is from the Code Project article (v1.5.0.12199). I have looked at the Container's GetInstance)() code and also the InstanceProducer's…
1
vote
2 answers

Is it bad to register more classes than needed with autofac?

I would like to use a common Autofac module in several different web projects. One of these projects does not require all the classes registered in my common module (it uses about half of them). My guess was that if a class is registered but never…
ThunderDev
  • 1,118
  • 2
  • 19
  • 38
1
vote
1 answer

Simple Injector: Inject External Web Service

I am having some difficulty in how to configure DI correct using SimpleInjector. I have an external Web Service which bindings are located in Web.config file. My external Web service lives in Services Layer. My Web Layer contains the composition…
Ctrl_Alt_Defeat
  • 3,933
  • 12
  • 66
  • 116
1
vote
1 answer

Unity IOC container and how to resolve different instances of the same interface

I have a unity container that I am registering types within like so: IUnityContainer container = new UnityContainer() .RegisterType( "PopulationRate"…
Rob Packwood
  • 3,698
  • 4
  • 32
  • 48
1
vote
2 answers

How to resolve a Collection of Types from within the IoC Container

We're using MvvmCross in our app, and using the MvxSimpleIoCContainer In the app startup, we register all of our Migrations. it's easy do do since all migrations inherit from IMigration typeof (IMigration) .Assembly .CreatableTypes() …
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
1
vote
0 answers

Windsor Castle container disposing is too slow... any way to improve performance?

As part of the graceful .NET 4.5 application shutdown I want to dispose the instance of Windsor Castle IoC container. The container has about 100 objects that were instantiated during the application lifetime and subset of them have IDisposable…
matori82
  • 3,669
  • 9
  • 42
  • 64
1
vote
1 answer

The right way to do property dependency injection using Unity

I have a class that needs a dependency injecting. As the class is already an implementation of another abstraction, and its 'sibling' implementations may not share the same dependencies, I am attempting to use property injection and not constructor…
1
vote
1 answer

How to export the type when interfaces are derived from base interface in MEF

Below is my scenario. I am trying to associate the types to the interfaces by using the Export functionality during the initial bootstrap. However, MEF complains on ImportCardinalityMismatchException.I am fairly new to MEF and I couldn't figure out…
Hunter
  • 2,370
  • 2
  • 20
  • 24
1
vote
1 answer

StructureMap: Configure concrete classes at run time?

I know that Concrete Types can be configured with Structure Map the following way: ForRequestedType().TheDefault.Is.Object(new ColorRule("Green")); This works if you know the type ahead of time. I want to do it at run time, and there does…
7wp
  • 12,505
  • 20
  • 77
  • 103
1
vote
1 answer

Several view controllers in one view controller

I am using a view controller that has several containers in it, and each container has its own view controller. I want to know if [topMostViewController removeFromParentViewController] will also remove all of its children, so that I don't have any…
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
1
vote
1 answer

Injecting/resolving object that is almost a singleton

Background I'm using Castle Windsor as my IOC container in a WPF application. In this application, the user can open a single project file, which is modeled using a concrete version of an IProjectModel interface. So, at any given time there is…
1
vote
1 answer

How do I use a Type Discriminator field in my DTO to instantiate the appropriate domain object with DI?

I am looking for suggestions on how to map a single DTO class with a type discriminator to multiple domain classes. I have my DTO: public class FooData { public Guid Id { get; set; } public string Name { get; set; } public string…
Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
1
vote
1 answer

How to make "defered" value export with MEF?

I have a Caliburn Micro's bootstrapper and I use the MEF as IoC. One of interfaces implementors can throw exception from it's constructor. So, when I do the following: CompositionBatch batch = new CompositionBatch(); …
EngineerSpock
  • 2,575
  • 4
  • 35
  • 57
1
vote
2 answers

Staying open with DI/IoC containers

I am involved with several open source projects which taken together provide an application development framework. The question I have is what mechanism(s) should I provide for integrating them with each other? On the conceptual level the answer is…
mfeingold
  • 7,094
  • 4
  • 37
  • 43