inversion-of-control

Best practices for unit tests, mock objects, and ioc

Okay so I have been trying to get into IoC lately. However, I keep running into one hurdle - that is the fact that I love using mock objects. They are quick and painless to setup. However, if I use IoC all over the place in my code then it forces me to create test implementations (and configurations) of my objects instead of using moc...

Unity Container Disposing and XML Web Service

Hi, I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container's lifetime? Please bear in mind I have an XML Web service. ...

Dependency Injection: How to maintain multiple configurations?

Hi StackOverflow, Lets assume we've build a system with a DI framework which is working quite fine. This system currently uses JMS to "talk" with other systems not maintained by us. The majority of our customers like the JMS approach and uses it according to our specification. The component which does all the messaging is injected with ...

Abstractions should not depend upon details. Details should depend upon abstractions ?

In past couple of days, I have read about quite a lot about dependency injection/inversion of control/inversion of dependency. I think that, now my understanding of the concept is much better. But I still don't get the following from wikipedia: A. High-level modules should not depend on low-level modules. Both should depend on ab...

Linq to SQL DataContext Windsor IoC memory leak problem

I have an ASP.NET MVC app that creates a Linq2SQL datacontext on a per-web-request basis using Castler Windsor IoC. For some reason that I do not fully understand, every time a new datacontext is created (on every web request) about 8k of memory is taken up and not released - which inevitably causes an OutOfMemory exception. If I forc...

ASP.NET MVP Injecting Service Dependency

I have an ASP.NET page that implements my view and creates the presenter in the page constuctor. Phil Haack's post providing was used as the starting point, and I'll just the examples from the post to illustrate the question. public partial class _Default : System.Web.UI.Page, IPostEditView { PostEditController controller; pub...

IoC in complex environment

Here is the situation: ICategorized is used by ICategoryService to manage categories public interface ICategorized { ICategory Category { get; set; } } Then some class implements ICategorized. public class Cart : ICategorized { ... ICategory Category { get { return _categoryService.GetItemCategory(...) } set { _cat...

Appropriate Situation for Using IoC Container?

Let's say I have a common WCF service and console app project that do not change across client specific deployments. I have some interfaces in the common projects that are implemented by specific client code. The client code obviously changes from client to client. I'm thinking this would be an appropriate use for an IoC container. In my...

IOC with multiple databases that use same interface (StructureMap or any other DI Framework)

We've been experimenting with StructureMap, and I'm having trouble grasping how to handle situations where a single interface has multiple implementations. The code below shows an example where we have two databases that are both accessible from a single service. public class SomeController : Controller { private ISomeService _servi...

Where should I store a reference to my DI container?

I'm wondering how I should store/reference my dependency injection container(s). Is it alright to have a container be a static property on a static class? Or should I have the container be an instance variable on the application? I'm wondering what the pros and cons of each option are, and what is the best practice for this in web, mvc, ...

Unity view Registered Types during debug

Possibly a stupid question, but during debug I simply want to see the types that have been registered with my Unity container. I have tried going through the container in the watch window, but can't seem to find what I am looking for? I am expecting there to be a list of registered types somewhere? Thanks in advance ...

How to not pass around the container when using IoC in Winforms

I'm new to the world of IoC and having a problem with implementing it in a Winforms application. I have an extremely basic application Winform application that uses MVC, it is one controller that does all the work and a working dialog (obviously with a controller). So I load all my classes in to my IoC container in program.cs and crea...

How do I implement a delegate factory?

The documentation for Autofac has an interesting page describing its ability to automatically generate delegate factories. It also strongly suggests that you can get similar results without Autofac by writing them by hand. I'm using Unity for IoC and would like to avoid passing the container around to objects that need to create other o...

What IoC Containers Support Silverlight?

I'm looking for a list of IoC Containers that support Silverlight. I know that Unity and Ninject work with Silverlight, but I haven't found any information that suggests that other well known containers, like StructureMap, Castle Windsor or Autofac, support Silverlight. Has anyone used these, or other, containers or compared them with t...

Books on Unity or MEF

Anyone know if there are any books on Unity or MEF coming out in the next month or two? ...

Injecting Subsonic SimpleRepository class to controller

Hi, I'm tryingot get started with IoC, I have an MVC project in which is use subsonic, I'm trying to inject subsonic simplerepository to my controllers but I'm getting this error: StructureMap Exception Code: 205 Missing requested Instance property "connectionStringName" for InstanceKey "60b735fb-0a7f-4eb4-be04-635f6f32233d" Here is my...

Unity IOC, AOP & Interface Interception

I've been playing around with Unity to do some AOP stuff, setting up via IOC like: ioc.RegisterType<ICustomerService, CustomerService>() .Configure<Interception>().SetInterceptorFor<ICustomerService>(new InterfaceInterceptor()); ... and then having an ICallHandler on the ICustomerService interface's methods. For teh time being i w...

MVC 2 Beta DefaultControllerFactory with Areas

Why default factory WON'T return full name of the controllers (with namespaces)? I'm using Service Locator and autofac. using System.Web.Mvc; using Microsoft.Practices.ServiceLocation; namespace Application.Core.MVC { public override IController CreateController(System.Web.Routing.RequestContext requestContext, string **contr...

Validate interface using IoC

Hi guys, I have a domain model that uses IoC with Microsoft Unity. For the validation I use VAB and I decorate the interface, not the entity. The code the following: interface IJob : IValidable { [NotNullValidator] string Name { get; set; } } interface IValidable { bool IsValid { get; } void ValidationResults Validate(); } class J...

Inversion of Control container, which one do you prefer?

Possible Duplicates: .NET IoC Container Comparisons Enterprise Library Unity vs Other IoC Containers I've been introduced to several IoC-containers during these past few months, and so far I can't really see a big difference from StructureMap, Windsor or Unity for that matter. Often I have heard groans from more senior develo...