inversion-of-control

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 performance reasons. However, sometimes this resource can transition into ununusable state, and...

Which .NET dependency injection framework do you use?

Currently there are quite a few DI/IoC-frameworks for .NET out there (http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx). I find it quite hard to choose. Therefore I wanted to measure the public opinion and see which framework is the most popular - so please post your favorite framework here and let the people ...

ServiceContainer, IoC, and disposable objects

I have a question, and I'm going to tag this subjective since that's what I think it evolves into, more of a discussion. I'm hoping for some good ideas or some thought-provokers. I apologize for the long-winded question but you need to know the context. The question is basically: How do you deal with concrete types in relation to IoC ...

Shoud I make an IUnityContainer object use a Singleton pattern?

Howdy, I am new to using Unity and IoC/DI concepts. I started with the concept by rolling my own via James Kovacs' show on dnrTV in a test. His example had the Container run as a singleton accessed through a static method in an IoC class so you could register types at a startup and resolve the type throughout your application. ...

Injecting a dependency into a custom ModelBinder

Hey all I have an ASP.net MVC project in the works at the moment, and I'm wondering if the following could be possible: I have a custom ModelBinder class that has a reference to a service (essentially a fetcher) as a dependency. I want the dependency to be injected using an IoC container (currently Ninject) but there seems to be nowhere...

What DI/IoC framework should I learn next?

I've used Spring and Spring.NET quite a bit, but I would like to see what else is out there. Can anyone recommend a good Java or .NET framework that I could try to learn? ...

StructureMap creating instance

I have the concrete types for interfaces configured at startup, but I want to create instances of the concrete type at runtime with setting properties or setting different values in the constructor. All the creating of instances I see have the knowledge of what the concrete type is, at runtime I dont know the concrete type. Is there a ...

How to use Dependency Injection with ASP.NET

I am trying to work out a way to use Dependency Injection with ASP.NET controls. I have got lots of controls that create repositories directly, and use those to access and bind to data etc. I am looking for a pattern where I can pass repositories to the controls externally (IoC), so my controls remain unaware of how repositories are co...

NInject: Where do you keep your reference to the Kernel?

I'm using NInject on a new web application and there are two things that are unclear to me: Don't I need to keep a reference to the Kernel around (Session/App variable) to insure that GC doesn't collect all my instances? For example, if I specify .Using() and then the Kernel object gets collected, aren't all my "singletons" collected ...

Implementing OnePerSessionBehavior in NInject...

I'd like to create a OnePerSessionBehavior for NInject (v1.0) and I've mostly got it working. The only issue that remains is how to pass in fresh arguments using .WithArguments() as each new session asks for something from the container. Right now I'm keeping a reference to the container as an application variable and therefore the mod...

What is IOC? Need some practical code examples to illustrate

Hi, Can someone guide me to some basic tutorials on IOC? (preferably .net/c#). I need some hands on code to wrap my head around it :) Is IOC similiar to DDD? or test-driven-design? ...

How can I avoid large multi-step unit tests?

I'm trying to unit test a method that performs a fairly complex operation, but I've been able to break that operation down into a number of steps on mockable interfaces like so: public class Foo { public Foo(IDependency1 dp1, IDependency2 dp2, IDependency3 dp3, IDependency4 dp4) { ... } public IEnumerable<int>...

How do I use InstanceScope.HttpSession in StructureMap?

I'm trying to use StructureMap's InstanceScope.HttpSession feature and I'm running into problems. I have the following method I'm using for testing: public static class StructureMapTest { public static T Get<T>() { ObjectFactory.Configure(x => x.AddRegistry(new RepositoryRegistry())); return ObjectFactory.GetInstanc...

Is the provider pattern an implementation of IOC?

Is the provider pattern an implementation of IOC? If not, why not? (reading through martin fowlers article on ioc) ...

dll "drop in" architecture using Castle Windsor & MicroKernel

I'd like to create a framework that uses IoC without needing any configuration: So instead of (adjusted from http://www.castleproject.org/container/gettingstarted/part1/code.html): IWindsorContainer container = new WindsorContainer(); container.AddComponent("someinterface", typeof(ISomeInterface)); ISomeInterface component = (ISomeInte...

Can someone explain Microsoft Unity?

I've been reading the articles on MSDN about Unity (Dependency Injection, Inversion of Control), but I think I need it explained in simple terms (or simple examples). I'm familiar with the MVPC pattern (we use it here), but I just can't really grasp this Unity thing yet, and I think it's the next step in our application design. ...

TDD for a Device Communicator

I've been reading about TDD, and would like to use it for my next project, but I'm not sure how to structure my classes with this new paradigm. The language I'd like to use is Java, although the problem is not really language-specific. The Project I have a few pieces of hardware that come with a ASCII-over-RS232 interface. I can issue...

Is this an example of Inversion of Control?

I just finished James Kovac's article on Inversion of Control and Dependency Injection and then used what I learned to make my own IoC/DI example below. I'm quite satisified with this example since it: satisfies the testability aspect of IoC in that it instantiates Customers by passing both a Repository and a MockRepository also the ...

Castle Windsor Cannot find my Service Type

Hey everyone.. Trying to make use of the Castle Windsor IoC. I have a very simple application. My interfaces exist in Test.Services namespace. I get the following exception when compiling: "The type name Test.Services.IParse, Test.Services could not be located" This is my app.config: <configuration> <configSections> <section na...

Prolems Wiring Up Event Subscribers in Castle.Windsor Framework

I am having trouble wiring the events for my Castle.Windsor IoV components. Even though I have confirmed the methods and the signatures for them, it throws an exception with the message "Object does not match target type". Can anyone please explain what object exactly its expecting? My wiring looks like: <component id="mailMa...