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

C# class constructor precondition

Lets say I have a class, with a constructor public RepresentativeService(IUserContext userContext, INavServiceClient navServiceClient) { _userContext = userContext; _navServiceClient = navServiceClient; } I would want to add…
Margus
  • 19,694
  • 14
  • 55
  • 103
1
vote
1 answer

Overriding Lifestyle when Registering a Collection?

I have configuration where I need to register two controllers that are simply: public class DataApiController : ApiController { readonly Data _data; readonly MongoRepo _mongoRepo; readonly JobManager _jobManager; readonly…
bryan
  • 1,031
  • 2
  • 17
  • 36
1
vote
1 answer

StructureMap registration

Imagine interface IRepository IFooRepository : IRepository IBarRepository : IRepository With associated Repository: FooRepository : RepositoryBase, IFooRepository BarRepository : RepositoryBase, IBarRepository I'm trying to do generic…
Arnaud
  • 84
  • 1
  • 10
1
vote
2 answers

What should be injected as C'tor paramter under DI principles?

I'm trying to understand which objects should be injected into an object and which should be created internally. If i have some List (as data field) which holds infomation gathered during run time. it seems that i should init it in the c'tor…
Adiel Yaacov
  • 1,401
  • 3
  • 14
  • 24
1
vote
1 answer

What is a correct approach to register several instances for the same type in Windsor Container?

I am using CommonSrviceLocator with WindworContainer for resolving my NHibernage.ISession instances. ISession instances is created through SessionFactory. For some reason I need to work with different databases in one application, so I need…
Restuta
  • 5,855
  • 33
  • 44
1
vote
1 answer

Laravel IoC bind method

When binding an implementation for given Interface or Abstract class, e. g $app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); how laravel determines that given implementation is one of the implementations of…
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
1
vote
1 answer

How to use "Quartz.NET" with "SimpleIOC" of MVVM Light Toolkit?

How can I integrate the Quartz.NET scheduling library with SimpleIOC, the IoC Container included in Laurent Bugnion's MVVM Light Toolkit? My current plan is to simply register the Quartz scheduler factory and then get its instance whenever needed…
1
vote
1 answer

Simple Injector with WebForms

Background I'm helping another developer put together a demo application as a poster child for creating tests, using a DI Container, project structure and other things that will increase code quality while hopefully allowing us to release more…
1
vote
1 answer

How can I define generic exports without relying on the IOC libraries?

I am working on a library which needs to make use of the common service locator (http://commonservicelocator.codeplex.com/) to provide generic IOC support in order that we don't conflict with any consumers. Obviously I don't want to reference the…
stimms
  • 42,945
  • 30
  • 96
  • 149
1
vote
1 answer

Laravel 5.1 Custom Facade Stopped Working

I am trying to make custom Facades for my Laravel 5.1.17 application. I have followed the Laravel documentation as well as this tutorial step by step and indeed I was able to create a custom Facade for my custom service. However, all of a sudden it…
tam5
  • 3,197
  • 5
  • 24
  • 45
1
vote
1 answer

Load objects with parameters from Laravel IoC container

I need a way to load objects via IoC provider depending on a request parameter. Right now I'm loading my objects directly with App::make(xy, [$urlParamter] which I want to refactor, so that I can use dependency injection the way it is supposed to.…
patriziotomato
  • 591
  • 1
  • 11
  • 25
1
vote
0 answers

Is this the Correct/Intended use of Spring IOC?

What is the usual practice to instantiate domain objects? Suppose in an architecture like following: @RestController public class MyController implements ServletConfigAware { private ApplicationContext context; …
Anmol Gupta
  • 2,797
  • 9
  • 27
  • 43
1
vote
0 answers

Can an IOC Container AssemblyLoad Event / Static Injection?

I anticipate having various assemblies that each contain a static class, with a static property, that might need to be "set" the moment the assembly they are in is loaded. This other post has an example of a static class that could benefit from such…
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
1
vote
2 answers

ASP.NET MVC controllers in separate assembies and Castle Windsor

I need to find a way to put my MVC controllers into a different project from the MVC project. I think I'm close. I've setup the Castle Windsor IoC container, and have my controllers in a different project. I think it's hanging up on the Web.Config.…
jchapa
  • 3,876
  • 2
  • 25
  • 38
1
vote
1 answer

how to use Unity with constructor injection to update the status in parent view of viewmodel1 using the child view & and its viewmodel2 in wpf

This is my UnityResolver Class to create the instance of IUnityContainer public sealed class UnityResolver { private static IUnityContainer _unityContainer; private static volatile UnityResolver _unityresolverinstance; private static…