inversion-of-control

Unity interception behind the scenes

I wonder how Unity interception works behind the scenes? I mean interface,transparent proxy and virtual method proxy interceptors implementation. Anyone could shed some light on this? ...

Simplest explanation of how a DI container works?

In simple terms and/or in high-level pseudo-code, how does a DI container work and how is it used? ...

ASP.Net MVC, Ninject IOC.

I'm using Ninject to do some dependancy injection. (Mainly for the DAL), my project consists of 3 aspects and are as follows, Project.Lib (Everything database, services and anythign else that is logic) Project.Admin (Administration) Project.Web (Front end what the user see's) Now, each of my controllers within my projects inherit fro...

Unity 2.0: How to create child containers on CTor injection?

Hello, I have a MessageSender class that its constructor looks like this: public MessageSender(IInputComponent input, IOutputComponent output) { m_Input = input; m_Output = output; } This is how I instantiate it: Container.RegisterType<IMessageSender, MessageSender>(); Container.RegisterType<IInpu...

MSMQ/.EXE vs. Web Service.... MEF IoC?

We are debating to correct way to setup a notification service. This serivce will be called by various apps and the service will need to return relevant data back. My feeling is you just create a Web service that the intranet portal (or anything) could access by sending the user ID and in return getting any information (User 425 report ...

Does Funq IoC Container support property injection?

Hi, I'm looking for an IoC container to use in my Compact Framework application. Trying out Funq I noticed that I can't find a way to do Property Injection with it. I've looked through the discussion on the project's site and the unit tests for it, but I can't find any example of Property Injection. Does Funq support Property Injecti...

Is Dependency Injection a pattern and, is this it?

I was having a heated debate with one of my colleagues on dependency injection, and realized I didn't quite know all the facts on the subject. So, take this code (just so you know,we're using Castle Windsor) IPlayerService service = Container.Resolve<IPlayerService>(); The above code is obviously an example of DI using an IoC. Howev...

How to inject to all child objects automatically

Hello all, Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} } i have an application that i want to enhance and simultaneously refactor for simplicity. I have over 100 classes that call some same stuff (e.g Class Injectable) and i am thinking that this behaviour can be abstracted and set t...

Binding singleton to multiple services in Ninject.

Hi, I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types. I'm using the latest release of Ninject 2 for Compact Framework and the exact issue I'm havin...

Making Custom IoC - How to Implement DI That Has Scope?

I'm writing an IoC container for my own learning/growth. Normally I would write something like the following: using(DisposableObject dispObj = new DisposableObject()) { UserRepository users = new UserRepository(dispObj); // Do stuff with user. } Would turn to: using(IDisposableObject dispObj = Container.Resolve<IDisposableOb...

C# Dependency Injection problem

I have 3 classes: A, B, and C All of these classes implement an interface IMyInterface I would like the interface to be defined like so: internal IMyInterface<E> where E: class { E returnData(); } So that it can return data of type E. The type "E" will be a POCO object created with the Entity Framework v4. In a separate class I...

Remove Dependency on IoC Container

After reading more and more about IoC containers, I read this post about not having IoC.Resolve() etc in your code. I'm really curious to know then, how can I remove the dependency on the container? I'll want to write code like the following: public void Action() { using(IDataContext dc = IoC.Resolve<IDataContext>()) { ...

C# Dependency Injection Cast Issue

I have several classes that implement the same interface. interface IBidManager<E> where E : IEntity public class BidManager : IBidManager<EntityObject1> public class BidManager2 : IBidManager<EntityObject2> public class BidManager3 : IBidManager<EntityObject3> In my business manager class I have: public class BusinessManager : Mana...

What beans do you wire in a spring mvc app?

I am wiring my UserService type classes using spring's IOC. But what about my User class? I have a interface User, then a UserImpl class. In my controller action's do I just do: User u = new UserImpl(); Or would it sometimes make sense to use IOC for this also? Sometimes I use a different constructor also when instantiating a cla...

Castle Windsor Transient Lifestyle Not Activating

Hi, I'm having a problem with a component in my container with a Transient lifestyle. The first time I call resolve, I hit the constructor of the implementation type as expected. However, the second time I call resolve, a new instance is not constructed. Rather, the existing instance is reused. I don't think this should happen, since ...

Unity: pass parameters to custom lifetime constructor, in xml configuration file

I wrote my CustomLifetimeManager like this: public class CustomLifetimeManager <T> : LifetimeManager { private readonly string _arg; public CustomLifetimeManager(string arg) { _arg = arg; } } Now, it works easy configuring the container programmatically, but how add it in configuration file like the following? ...

Implement Interface Without Creating Implementation (Dynamic Proxies?)

I've been working on creating my own IoC container for learning purposes. After asking a couple questions about them, I was shown that creating a factory to "resolve" the objects was the best solution (see third solution here). User Krzysztof Koźmic showed that Castle Windsor actually can implement this for you. I've been reading the so...

Interface arguments in ASP.NET MVC

I'm in the process of developing an ASP.NET MVC project, and after several weeks of research, I have a pretty good framework in place using StructureMap to register my dependencies at bootstrap time, create my controllers with the correct implementations, a custom model binder for passing data to my controller, etc. After thinking about...

Inversion of Control < Dependency Injection

I'm getting the feeling that there's is not such thing as inversion of control or rather the correct term is dependency injection. Am I wrong to assume this? I've been trying to define IoC for my own sake. In doing so I've learned a great deal about IoC containers and dependency injection. Just now, I read this from Martin Fowler's web...

Spring: Using builder pattern to create a bean

I use ektorp to connect to CouchDB. The way to build an ektorp HttpClient instance is to use builder pattern: HttpClient httpClient = new StdHttpClient.Builder() .host("mychouchdbhost") .port(4455) .build(); I am relatively new to Spring. P...