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

Parameterized controller constructor never gets hit

With my pet project I'm trying to learn to use Turbine as a DI container. I'm registering unity as locatorprovider as such: static MvcApplication() { ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator()); } My user…
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
1
vote
1 answer

Spring Java Configuration Overriding Beans

I have a problem with creating two beans of the same class but different qualifier name. Basically One bean is created with the annotations @Repository and the other one is creating inside @Configuration class. This is the class that we wont two…
Gerard Ribas
  • 717
  • 1
  • 9
  • 17
1
vote
1 answer

StructureMap: differences between explicit vs scanned registrations

I have a situation where I want custom code to be able to override existing registrations. For example I have an interface, public interface IInterface{ int Num {get;set;} That by default resolves to, public class CoreClass: IInterface{...} (NB.…
Matt Cotton
  • 732
  • 9
  • 23
1
vote
1 answer

Ninject getting Null when use StandardKernel.Get()

I have two branches under my master interface, and try to use Ninject IOC here to dynamically load proper class based on some condiction. here is my description of my class structure and problem I have Interface I { Void method1 (); …
1
vote
1 answer

How to specify named instance as constructor parameter for type that are auto-registered for StructureMap

Using StructureMap, We have all types that are auto registered. public class MessageRegistry : Registry { public MessageRegistry(){ Scan(x => { x.AssemblyContainingType(typeof (FormatHelper)); …
1
vote
1 answer

StructureMap - Circular Dependencies and Lazy Initialization of Setter Properties

So we have ran into what seems like a very common issue with StructureMap and IoC containers in general I assume. Bidirectiona/Circuar dependencies. Given the following code, it is currently causing a circular dependency since we have it…
TheJediCowboy
  • 8,924
  • 28
  • 136
  • 208
1
vote
1 answer

Performance impact on SimpleInjector's Container.GetInstance() method

I know that the performance and speed of SimpleInjector is very good but anyway I need to figure out how big is the overhead of calling the Container.GetInstance() method. For example if I have the following class: public class ServiceManager { …
1
vote
3 answers

Laravel 4: how to inject another class in a eloquent model

I'm trying to use the built-in laravel's Ioc container to inject a PageManager class inside a Page model and I'm a little lost. What I'm trying to achieve is something like that: class Pages extends Eloquent { public function…
Ingro
  • 2,841
  • 5
  • 26
  • 42
1
vote
1 answer

Using Autofac with Dynamic Proxy that output message automatic

public interface ILog { void Write(string msg); } public class MyLog : ILog { public void Write(string msg) { Console.WriteLine(msg); } } public interface ICanLog { ILog Log { get; set; } } public interface IMyClass { …
Flash
  • 1,615
  • 4
  • 17
  • 23
1
vote
2 answers

Does MS PnP Unity Scan for Assemblies Like StructureMap?

In Using StructureMap 2.5 to scan all assemblies in a folder, we can see that StructureMap uses AssembliesFromPath() to explicitly look for types to resolve. What is the equivalent of this in Microsoft Unity? Because Unity is such a generic term,…
rasx
  • 5,288
  • 2
  • 45
  • 60
1
vote
1 answer

Is it right to use IoC for the extensibility of my entities or domain model?

I've came across a dilemma which I think is worth discussing here. I have a set of domain objects (you can also call them entities, if you like), which get some data from a separate DAL which is resolved with an IoC. I was thinking about making my…
Venemo
  • 18,515
  • 13
  • 84
  • 125
1
vote
1 answer

Resolving a Dependency with ServiceStack IoC Container

I have a repository that implements MongoRepository which uses generics I'm trying to register the type in the container so far this is what I got: public override void Configure(Container container) { …
pedrommuller
  • 15,741
  • 10
  • 76
  • 126
1
vote
1 answer

Autofac lifetime scope registrations sharing, Integration tests setup

My case is quite common but i cannot find an answer. I have integration tests where on each setup some services are mocked. I have to update Autuofac container to get constructor injection of those mocks. So basically I have main container with all…
1
vote
2 answers

TinyIoC and the decorator pattern

Can someone please provide a simple example of how to implement the decorator pattern with TinyIoC? A previous question shows how to do this in Ninject with the following: Bind().To
Ken Burkhardt
  • 3,528
  • 6
  • 33
  • 45
1
vote
1 answer

Castle windsor - null object with Dependecy Injection of class that inherits from a generic base class

I'm experiencing problems with Castle.Windsor Dependency Injection. I'd like to register in the container all my service layer with the related Dao. I'd also like to obtain Propery Injection instead of Constructor injection. When I run the…