inversion-of-control

How to carry out custom initialisation with autofac

I'm adding autofac to an existing project and some of the service implementations require their Initialize method to be called and passed configuration information. Currently I'm using the code: builder.Register(context => { var service = new SqlTaxRateProvider( context.Resolve<IUserProvider>() )...

Customizing Autofac Controller registration

I am trying to use Autofac and Autofac.Integrations.Web to register ASP.NET MVC controllers. I am currently using assembly scanning to find the controllers but one of them needs a special parameter that I would prefer to pass in instead. Found below are the registrations I have tried. var builder = new ContainerBuilder(); builder.Regis...

Using Ninject 2.0 with ASP .Net 3.5

Hi, I am trying to use Ninject 2.0 with Asp .Net 3.5 web application. Following are the DLLS and it's versions I am using. Ninject.dll - v2.0.0.0 Ninject.Extensions.Logging.dll v2.0.0.0 Ninject.Web.dll v1.0.0.0 In my global.ascx.cs I have following method. protected override IKernel CreateKernel() { IKernel kernel = new...

Confusion with interfaces, factories, and inversion of control.

Using interfaces is a very easy way to remove dependencies, but what happens when one of your classes needs a method not defined by the interface? If you're using constructor injection or a factory, how do you access that extra method without casting? Is this possible? Here is an example of a factory with this problem. Am I trying to do...

MEF & separate Interface assembly leads to "Interface for every class"

I'm getting my feet wet with DI/IoC and MEF in particular. I have a web application that has two types of parts (maybe more someday) defined by interfaces which need access to the whole environment. The application has a list with concrete implementations for each type, composed by MEF. The environment consists of: several repositori...

How to connect an ORM to the IoC container?

Hello, been searching a lot information about IoC/DI development, but I haven't found much information how to integrate an ORM into the IoC/DI development. Should the IoC know about the ORM? Or vice versa? How does the IoC configuration mapping work when mapping a "ORM type"? Example: public class Person : IPerson { private IPer...

Utility of IoC and Dependency Injection

There are some cases in which unit test don't work for the project. I'm studing the Inversion of Control and Dependency Injection utilities and I would like to know if there are good reasons for use it than for make unit tests easier. --update Ok, let's analysis 1 of the cited advanteges: less coupling. You take out the coupling from ...

Multi tenancy with Unity

Hi everybody! I'm trying to implement this scenario using Unity and i can't figure out how this could be done: the same web application (ASP.NET MVC) should be made accessible to more than one client (multi-tenant). The URL of the web site will differentiate the client (this i know how to get). So getting the URL one could set the (l...

GWT Acegi alternative

I'm starting new project. The client interface is based on GWT (and GXT) I have no say it's predetermined. However I can pick and choose as far as server side so I can have some fun and hopefully learn something new in the process. Some requirements are : Exchange with server will be through use of JSON, most if not all of UI will be g...

Dependency Injection Constructor Madness

I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this: public MyClass(Container con) for every class? What are the downsides? If I do this,...

Windsor XML configuration of generics

Hi everybody! How do i setup the configuration in XML (for Windsor Castle) for the following class? public class Repository<T> : IRepository<T> where T : class { .... } I know how to do it in code but i must use XML file Thanks in advance ...

Unity framework - creating & disposing Entity Framework datacontexts at the appropriate time

Hi there, With some kindly help from StackOverflow, I've got Unity Framework to create my chained dependencies, including an Entity Framework datacontext object: using (IUnityContainer container = new UnityContainer()) { container.RegisterType<IMeterView, Meter>(); container.RegisterType<IUnitOfWork, CommunergySQLiteEntities>(n...

Scaling Java applications - existing cluster-aware IoC frameworks?

Most people use some kind of an IoC framework - Guice, Spring, you name it. Many of us need to scale their applications too, so they complicate their lifes with Terracotta, Glassfish/JBoss/insertyourfavouritehere clusters. But is it really the way to go? Are you using any of the above? Here's some ideas we currently have implemented in...

Using IOC in a remoting scenario

I'm struggling with getting IOC to work in a remoting scenario. I have my application server set up to publish Services (SingleCall) which are configured via XML. This works just like this as we all know: RemotingConfiguration.Configure(ConfigFile, true); lets say my service looks like that (pseudocode) public class TourService : IT...

Best IoC practices in large projects

What techniques have you found useful for managing dependencies of large projects with Inversion of Control containers? Do you bootstrap everything in one place, or do you split it up? Do you ever use multiple containers? ...

Why is IoC / DI not common in Python?

In Java IoC / DI is a very common practice which is extensively used in web applications, nearly all available frameworks and Java EE. On the other hand, there are also lots of big Python web applications, but beside of Zope (which I've heard should be really horrible to code) IoC doesn't seem to be very common in the Python world. (Plea...

Spring: How to assure that a class is only instantiated by spring and not by keyword new.

Hi, Is it possible to assure that only spring can instantiate a class, and not by the keyword new at compile time? (To avoid instantiating by accident) Thank you! ...

How should I be using IoC in this winform piece of code?

Hi folks, I've got a winform app in visual studio 2010. My app does the following Get a list of files which I need to read the data then insert into a database. For each file, read data and insert into DB. So .. this is the code i have. // ******* // *** How should the _repository be Injected?? // ******* var list = _repository.Get...

Resolve dependency with autofac based on constructor parameter attribute

I'm using Autofac. I want to inject a different implementation of a dependency based on an attribute I apply to the constructor parameter. For example: class CustomerRepository { public CustomerRepository([CustomerDB] IObjectContainer db) { ... } } class FooRepository { public FooRepository([FooDB] IObjectContainer db) { ... } ...

What is PocoCapsule current status?

What is PocoCapsule current status? Is it evolving? Has it been forked with some other product? What is about the whole idea of IoC for C++? If PocoCapsule is not evolving, is it because IoC was considered not useful for C++, unsafe, other patterns appeared or something else? As far as I understand there are 2-3, maybe few more products...