inversion-of-control

Spring- How to use Spring Dependency Injection to write a Standalone Java Application

I want To write a standalone application with IOC,How do i use springs dependancy injection in there. Im using JIdea. There is spring 2.5 support but i want to use spring 3.0 here is the way i tried! I experience in using Spring MVC we can inject dependancies there in a WebApplicationContext but how do i inject dependancies in a st...

What preferred way to wire dependencies using IoC container?

I believe that most IoC containers allow you to wire dependencies with XML configuration file. What are cons and pros for using configuration file vs. registering dependencies in code? ...

Why do I need an IoC container as opposed to straightforward DI code?

I've been using Dependency Injection (DI) for a while, injecting either in a constructor, property, or method. I've never felt a need to use an Inversion of Control (IoC) container. However, the more I read, the more pressure I feel from the community to use an IoC container. I played with .NET containers like StructureMap, NInject, U...

Castle Windsor resolving and generics

Hi guys I have the following: public interface ISubject { ... } public class Subject<T> : ISubject { ... } public class MyCode<T> { ... pulic void MyMethod() { var item = container.Resolve<ISubject>(); //????? how do I pass in T } ... } In this case how do i do the resolve. Cheers Anthony ...

Will IoC lead to too many params for ASP.NET MVC Controller constructor?

I have decided to use ASP.NET MVC for a website project and want to follow some of the best practices being written about. So, I have separated out the Domain/Model into a separate project, created IRepositories and concrete repositories and have now turned my attention to Castle Windsor as the IoC. The problem I now face is that for a...

Which Dependency Injection technique should I use in dotnet?

[Revision 5/14/09: I need this to target Dotnet 2.0 because of my deployment scenario] I am new to Dependency Injection & IoC. I see that there are a plethora of containers and libraries to help the process along. What are the pros and cons of using these libraries. What is your favorite (dotnet) container and why? What about rollin...

IOC and dynamic parameters...

I have read some posts on here about not mixing parameters when passing into a constructor, but have a question. I have classes and they all depend on a company parameter, all of the methods are dependent on the company. I do not want to have to pass the company in on every method call, I would like to pass that into the constructor. ...

Windsor Castle :- Inject Dictionary of Interfaces via configuration

Hi i am trying to inject a dictionary of interfaces but am getting an error from castle like this :- Castle.MicroKernel.SubSystems.Conversion.ConverterException: No converter registered to handle the type IFoo In order to go around the exception, I had to create a wrapper that contained a list of the Ifoo interface and returns it using...

Can anyone explain to me, at length, how to use IOC containers?

I use dependency injection through parameters and constructors extensively. I understand the principle to this degree and am happy with it. On my large projects, I end up with too many dependencies being injected (anything hitting double figures feels to big - I like the term 'macaroni code'). As such, I have been considering IOC contai...

Castle Windsor Ioc Resolving Generic classes in the web.config

I have an interface declared as IRetrievable<T, idT> where T is the retrieved type and IdT is the argument passed. How do I configure the castle windsor IoC container to resolve that to a specfic Implementation. Such as a class defined as FooRetriever : IRetrievable<Foo, string> I found an example that showed how to resolve a sing...

In StructureMap, how can I change the InstanceScope at runtime?

In my DefaultRegistry I have this configuration: ForRequestedType<INHUnitOfWork>().CacheBy(InstanceScope.HttpContext) .TheDefault.Is.OfConcreteType<NHibernateUnitOfWork>(); At some point in the web application flow I want to change the InstanceScope to HttpSession to obtain a long conversation, so I do this: PluginTypeConfigu...

What are the advantages of using a concept like IStartable?

Instead of using an interface like this: public interface IStartable { void Start(); void Stop(); } I usually just make the constructor of an object run the Start() code, and implement IDisposable so that the dispose method runs the Stop() code. Is it just a matter of style? Or am I missing something important by not having s...

Illustration for code presentation

I got an odd request, and I fear it will be closed as off-topic. So be it, but it's worth a shot. I'm creating a presentation about dependency injection and inversion of control, and I thought I'd make the point of interchangeable parts that serve a common purpose, but has different implementations, by showing an image I've seen before....

Specifying instance for registration of a component with Castle Windsor

Hi, I have what is probably a simple question here about Castle Windsor, which I haven't been using for very long. I'm trying to register a service with a specific instance that will be the singleton implementation of the service. The container cannot try to create the implementation of the service itself because it has dependencies tha...

ASP.NET MVC: Using Kigg as a base MVC application

Looking to create my first MVC application. Coming from WebForms I'm pretty excited to create an application that I can easily test. I have looked into Kigg (the Digg clone done in MVC) and from the looks of it, it uses many of the best-practices in its architecture. Having said that, would their approach be a good basis to base my we...

What is Component-Driven Development?

Component-Driven Development term is starting to get used widely, esp. in connection with Inversion of Control. What is it? What problems does it solve? When is it appropriate and when not? ...

IoC, AOP and more

What is an IoC container? What is an IoC/DI framework? Why do we need a framework for IoC/DI? Is there any relationship between IoC/DI and AOP? What is Spring.net/ninject with respect to IoC and AOP? ...

IoC vs global variable in library.

So say that I have type that takes some parameters in the constructor, like this: public MyType(IComObject wrapper,string table) {} now IComObject is a wrapper over a two different COM objects. All(90%) of my types have to use IComObject, so in good DI fashion (to allow for testing) I am passing IComObject into every type that needs...

Dynamic Business Rules in a web application

Greetings! Working on a web based project were business rules and logic need to be customized by client. I want to do this without having to recompile the application every time we sign up a new client on the system. The architectures I have outlined so far are: Windows Workflow: Creating dynamic workflows and saving them to the dat...

Having overload methods that use IoC container.

I am writing a API over the top of a COM object and you have to pass around the COM object into pretty much every type and static method that I write so that I can test each part of my API. Now my question is do I have an overloaded method for the one that takes the COM object but pass the IoC resolved one instead to the other one inste...