inversion-of-control

Help me with architecture to encapsulate my databases (maybe DI/IoC?)

I'm building a Windows-forms application that does some analysis that depends on 3 different databases. Two are actually geographic databases (ESRI) and one is a standard CRUD-type repository of information. Let's call them GeoRefDatabase, GeoResultDatabase, and RulesDatabase, respectively. There will be different types of analysis clas...

How To Centrally Initialize an IOC Container in MbUnit?

We currently have a suite of integration tests that run via MbUnit test suites. We are in the process of refactoring much of the code to use an IOC framework (StructureMap). I'd like to configure/initialize the container ONCE when the MBUnit test runner fires up, using the same registry code that we use in production. Is there a way o...

Is it bad to use servicelocation instead of constructor injection to avoid writing loads of factory classes

Right now we use DI/IOC and when we need to pass extra parameters to a constructor we use a factory class e.g. public class EmailSender { internal EmailSender(string toEmail, string subject,String body, ILogger emailLogger) {.....} } public class EmailSenderFactory { ILogger emailLogger; public EmailSenderFactory(ILog...

Best way to use an IoC container for retrieving runtime settings

I have an C# dll project for which I have to store the runtime settings in an external XML file, and this dll will be used in an ASP.NET/ASP.NET MVC application for which I also have to store the runtime settings in a external file. Which IoC container can be used to create an object with the runtime settings loaded from a specific exte...

Spring Philosophy

Everytime I ask anyone what is Spring Framework or what does it do ?, they simply say me, you remember that Hollywood Principle right "Don't Call me, I will Call you", that's exactly what Spring Framework does. What should I make out of this ? ...

Prefetching data in with Linq-to-SQL, IOC and Repository pattern

Hi, using Linq-to-SQL I'd like to prefetch some data. 1) the common solution is to deal with DataLoadOptions, but in my architecture it won't work because : the options have to be set before the first query I'm using IOC, so I don't directly instanciate the DataContext (I cannot execute code at instanciation) my DataContext is persis...

Run Time Object Graph Builder Composition Library

I am working on a project and have started to use IOC/DI (Unity) and I've looked into MEF. I have come across something which is related to IOC/DI and could probably reuse many of the components that IOC/DI containers use but which isn't the same. This scenario is close to what MEF is trying to accomplish, but rather than assume that f...

Repository pattern with Linq to SQL using IoC, Dependency Injection, Unit of Work

There seems to be lots of examples on implementing Repository pattern for Linq to SQL. Most of them featuring IRepository and DI; Some have implemented Unit of Work and some not. I tried to read as most of the results returned by searches on SO and Google on Linq to SQL repository patterns. Nevertheless I've not come across a complete so...

AutoFac Autowiring Conventions

StructureMap has the ability to apply conventions when scanning. Thus IFoo => Foo, without explicit registration. Is something simular available in AutoFac? Looked around and just can't find anything helpfull. Thanks, ...

Container Resolve based on criteria

I'm trying to implement the Strategy pattern while using Windsor container. Here is what I have: public class OrderProcessor { ... public OrderProcessor(ITaxStrategy strategy) {} public void Process(Order order) { order.Tax = strategy.CalcTax(order); } } The problem is, how do I configure my container (other c...

StructureMap Configuration Per Thread/Request for the Full Dependency Chain

I've been using Structuremap for a few months now, and it has worked great on some smaller (green field) projects. Most of the configurations I have had to set up involve a single implementation per interface. In the cases where I needed to choose a specific implementation at runtime, I created a factory class that used ObjectFact...

How to explain Dependency Injection to a 5-year old

Hello there, Could anybody point out a good dependency injection tutorial? I found a ton on Google but none of them that would assume the reader is a just Java beginner. Thanks! ...

How do I debug a Unity Container "Resolve"?

I'm using the MS Unity container to do dependency injection, but a "Resolve" is returning unexpected results. Is there an way I can debug this resolution? It would be great if I could view what Types/Instances are registered in the container, but I can't see where this is stored when using QuickWatch. It would also be useful if I could ...

IoC Dependancy injection into Custom HTTP Module - how? (ASP.NET)

Hi, I have a custom HTTP Module. I would like to inject the logger using my IoC framework, so I can log errors in the module. However, of course I don't get a constructor, so can't inject it into that. What's the best way to go about this? If you need the specific IoC container - I'm currently using Windsor, but may soon move to Aut...

Besides DI, what benefits can I get from an IoC container?

IoC Frameworks just make DI much easier, but it's not only DI that they do, they provide a host of other benefits over and above DI. I saw this comment in one of the answers to a question about DI and IoC. Can someone explain this in some more details? What are other benefits of IoC? ...

Why is this method call not getting intercepted?

Why doesn't DoIt() method call get intercepted? Should I use something other than InterfaceInterceptor to intercept the DoIt() method? How would you do it? using System; using Microsoft.Practices.Unity; using Microsoft.Practices.Unity.InterceptionExtension; namespace UnityTest { class Program { static void Main(string[] ar...

Resolving a Generic with a Generic parameter in Castle Windsor

I am trying to register a type like IRequestHandler1[GenericTestRequest1[T]] which will be implemented by GenericTestRequestHandler`1[T] but I am currently getting an error from Windsor "Castle.MicroKernel.ComponentNotFoundException : No component for supporting the service " Is this type of operation supported? Or is it to far removed ...

What is the best strategy for Dependency Injection of User Input?

I've used a fair amount of dependency injection, but I'd like to get input on how to handle information from the user at runtime. I have a class that connects to a com port. I allow the user to select the com port number. Right now, I have that com port parameter as a constructor argument. The reasoning being that the class cannot funct...

Can NInject load modules/assemblies on demand?

Are there facilities in NInject that will allow me to load services from other modules (assemblies) on demand like it's done in Unity? ...

Can StructureMap load modules/assemblies on demand?

Are there facilities in StructureMap that will allow me to load services from other modules (assemblies) on demand like it's done in Unity? ...