Questions tagged [inversion-of-control]

Inversion of control (IoC) is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming.

In traditional programming the flow of the business logic is controlled by a central piece of code, which calls reusable subroutines that perform specific functions. Using Inversion of Control this "central control" design principle is abandoned. The caller's code deals with the program's execution order, but the business knowledge is encapsulated by the called subroutines. In practice, Inversion of Control is a style of software construction where reusable generic code controls the execution of problem-specific code. It carries the strong connotation that the reusable code and the problem-specific code are developed independently, which often results in a single integrated application. Inversion of Control as a design guideline serves the following purposes:

  • There is a decoupling of the execution of a certain task from implementation.
  • Every system can focus on what it is designed for.
  • The systems make no assumptions about what other systems do or should do.
  • Replacing systems will have no side effect on other systems.

Dependency injection and Inversion of Control are closely related. The difference between them is discussed in this question.

Wikipedia: Inversion of Control

Related Patterns

4379 questions
2
votes
1 answer

Cannot resolve with IServerSideEvents dependancy

Extening on : IOC injection of IServerSideEvents I am trying to setup a Singleton on the container which requires IServerSideEvents (IMessager has the dependancy). // setup Engine List handler = new List() { new…
Barry
  • 357
  • 1
  • 11
2
votes
1 answer

IoC container for VBA

Had a nice read about DI here in VBA: https://rubberduckvba.wordpress.com/2016/07/05/oop-vba-pt-2-factories-and-cheap-hotels/ So now the next step would be use an IoC container in VBA. But I am wondering if that's even possible! I'm new to VBA and I…
2
votes
1 answer

Accessing the DBContext from classes in 2 different projects when one reads from DBContextBase and the other from DomainDBContext

I have a shared project that I put my shared and base logic in to reuse in other projects and a Normal asp.net core project on top of it. In the Shared base project I have: class DbContextBase : DbContext { public DbSet ActivityLogs {…
Ashkan S
  • 10,464
  • 6
  • 51
  • 80
2
votes
2 answers

Looking for way to pass Windsor lifestyle into a library

We have a web api project which references a library that in turn is shared between many different systems. The library exposes a "RegisterDependancies(IWindsorContainer container)" function that when called will register all of the dependencies for…
5NRF
  • 401
  • 3
  • 12
2
votes
1 answer

Autofac Parameter injection

I am misunderstanding the Autofac documentation on passing parameters to a Resolve method. The following is a minimalistic example of what I mean: Example https://dotnetfiddle.net/fz5eTp public static void Main() { var cb = new…
Thierry Prost
  • 1,005
  • 11
  • 22
2
votes
1 answer

Autofac Multiple Lifetime Scopes with single Container

I'm trying to figure out a work around for using multiple lifetimes with a single Container. The problem is related to InstancePerRequest() implementation. There is an application based on WebAPI with custom WebHandler, so Autofac can not define…
2
votes
2 answers

Using DynamicProxy as a decorator pattern in windsor container

I am looking for some info on using and configuring windsor to provide a dynamic proxy to intercept calls to an instance of another class. My class represents a resource that should be retained as a long lived instance by the container for…
2
votes
2 answers

How to use @Autowired in not Spring's stereotype classes

I would like to use that repository in this class, but when I put a stereotype like @Component, I get an error from the IDE: Could not autowire. No beans of 'Authentication' type found. public class CustomMethodSecurityExpressionRoot extends…
Bence Szabari
  • 143
  • 1
  • 2
  • 12
2
votes
2 answers

C#, Autofac: NamedParameter is not provided in Register<>

I'm trying some autofac features at the moment and are struggling with the NamedParameter. I created a very simple example, where IFoo is realized by HappyFoo and SadFoo. IFooUser expects an IFoo object in the constructor and uses it to print…
codefluent
  • 125
  • 1
  • 11
2
votes
1 answer

How to debug using UnityContainer Resolve?

0) How to debug unityContainer? Im working on a legacy project on the firm, and all projects are loaded using dependency injection using unityContainer. I need to make improvements on the presentation layer, but I cannot debug the code, only the…
2
votes
2 answers

How to register generic class with AutoFac that requires parameters?

AutoFac lets you register generic classes with builder.RegisterGeneric(Type type), however it does not accept parameters for construction. The description of the method even says: Register an un-parametrized geenric type However, what if I have a…
Loreno
  • 668
  • 8
  • 26
2
votes
4 answers

Spring IoC on WP7?

Is it possible to use Spring.net on WP7? Would you recommend others DI/IoC-Containers for WP7 and why?
Beachwalker
  • 7,685
  • 6
  • 52
  • 94
2
votes
1 answer

Castle windsor and IHttpHandler and IHttpHandlerFactory

I'm developing a RIA application where there is javascript on the client (i'm using Ext) and .NET on the server, for json-rpc I'm using Jayrock which is a nice library (at least for me) as it is simple and works well, Ive used it in the…
2
votes
1 answer

Passing parameters from composite root down the DI chain

I'm working on a project that has very little dependency injection and I'd like to start adding it incrementally. To test it out, I would like to expose an API endpoint, take the parameters passed to the API method by the calling client, create the…
Eitan
  • 1,434
  • 6
  • 21
  • 53
2
votes
1 answer

WPF/MVVM Navigation with child ViewModels having dependencies

I'm trying to use both MVVM and Dependency Injection pattern in my WPF MDI application. I'm using VM first approach. Basically, my app starts with the App.xaml.cs class which is supposed to be, if I understood the thing well, my composition root…
1 2 3
99
100