ioc-container

How do i handle static classes while using IOC

I just started migrating my web application to fully use Windsor IOC. Here is a little problem I am encountering; I have couple of static classes which I used to store some application level global values EG (Simplified version of the class): public static class SiteInfo { public static Language Language = (Language)byte.Par...

TDD, creating layer of abstraction

Hi guys, Basically, there is a system at my work place that provides OCR capabilities. The process is that, a third party application is configured to display a captured screen (during the OCR process) and a user sits at the pc making sure the captured data is correct. This capture stage has validation on each of the fields. for exampl...

Is it ok to register components in Windsor without specifying an interface?

Is it considered bad form to register components in Windsor without specifying an interface? i.e. container.Register(Component.For().LifeStyle.Transient); as opposed to... container.Register(Component.For().ImplementedBy().LifeStyle.Transient); I understand the benefits of coding to an interface rather than a concrete implementation ...

Is this a good reason to use IoC/DI?

Im new to the IoC/DI concept.. I have a good MEF demo which shows how you can make a program that accepts .DLLs that implement a certain interface and so you can have different filters on a picture http://www.wintellect.com/CS/blogs/jprosise/archive/2010/01/04/silverlight-4-s-new-managed-extensibility-framework.aspx So my case is a WC...

How to inject to all child objects automatically

Hello all, Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} } i have an application that i want to enhance and simultaneously refactor for simplicity. I have over 100 classes that call some same stuff (e.g Class Injectable) and i am thinking that this behaviour can be abstracted and set t...

How does autowiring work in spring?

I'm a little confused as to how the IOC works in spring. Say I have a service class called UserServiceImpl that implements UserService interface. How would this be auto-wired? And in my Controllers action, how would I instantiate an instance of this service? Would I just do: UserService userService = new UserServiceImpl(); ...

Remove Dependency on IoC Container

After reading more and more about IoC containers, I read this post about not having IoC.Resolve() etc in your code. I'm really curious to know then, how can I remove the dependency on the container? I'll want to write code like the following: public void Action() { using(IDataContext dc = IoC.Resolve<IDataContext>()) { ...

Property Injection in Base Controller using Ninject 2

I have the following code in my Global.aspx protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); } protected override IKernel CreateKernel() { return new StandardKernel(new ServiceModule()); } ...

spring IOC, can I drop a .jar that adheres to an interface and modify the app-config.xml?

Say I have a database layer, with DTO's for each table, and a factory that returns the DTO's for each table. As long as I build to interfaces, I can re-implement the db layer and then just change my app-config.xml to use another implementation. Now, is it possible for me to have this new implementation in another .jar file? The goal...

Use Spring IoC with servlets defined in web.xml

Hi all, This may be a relatively straight-forward question that I just haven't been searching for correctly, but I'm trying to use the Spring IoC container to configure my servlets. I have some additional handlers (that are private data members) and such that I would like to be configured at runtime. Is it possible to do this? Right ...

Using IOC container in silverlight to dynamically load assembly. Is this possible?

Hello, I have two silverlight assemblies. In assembly 1 I have implemented an interface ISnProvider. In assembly 2 I have a concrete class which implements the ISnProvider. I plan on having more assemblies which will contain different implementations of ISnProvider. Assembly 1 has no reference to assembly 2. When my silverlight app sta...

Unity 2.0: How does it work?

Hello, I'm using Unity and would love to read a good explanation about its internal works - mostly how it builds up objects. I am aware of this nice MSDN article - Getting to Know the Unity Application Block, and it has a great drawing of the proccess, but I'm looking for a more technical and detailed explanation. Can anyone direct me...

Ninject 2.0: Property Injection without attribute

Is there a way to use Property Injection in Ninject 2 without using the [Inject] attribute? This creates a dependency to Ninject in the class that will be wired using it and I prefer to avoid having unneeded dependencies to my IoC container, that's why I end up using Constructor Injection more often. I guess the same applies to Method I...

Using an Ioc Container at runtime within a factory to determine class initialization

Is this a good pattern? It has a code smell to me with having a factory class aware of the IUnityContainer... My basic need was to resolve an ICalculationRuleProcess at runtime depending on an Id of a class. It could be based on something other than the Id, I am aware of that... basically I have a known set of Ids that I need to deal ...

Options for IoC Auto Wiring in Domain Driven Design

In my latest ASP.NET MVC 2 application I have been trying to put into practice the concepts of Domain Driven Design (DDD), the Single Responsibility Principle (SRP), Inversion of Control (IoC), and Test Driven Development (TDD). As an architecture example I have been following Jeffery Palermo's "Onion Architecture" which is expanded on g...

How does Unity resolve types that have not been registered?

I'll admit it, I'm too lazy to look at the source code. Does anyone know? ...

How to use Unity in order to implement a simple component publishing engine.

Dear ladies and sirs. In our project we have implemented a simple facility to let one party publish dynamic components and yet others - to consume them. I would like to phase out our in-house implementation and take something ready off the shelf. Since our UI guys already use Caliburn+Prism+Unity, I decided to go with Unity (having two ...

ASP.NET MVC controllers in separate assembies and Castle Windsor

I need to find a way to put my MVC controllers into a different project from the MVC project. I think I'm close. I've setup the Castle Windsor IoC container, and have my controllers in a different project. I think it's hanging up on the Web.Config. Is there a component I need to add? Here is the current exception I'm getting: No com...

Can an IOC Container AssemblyLoad Event / Static Injection?

I anticipate having various assemblies that each contain a static class, with a static property, that might need to be "set" the moment the assembly they are in is loaded. This other post has an example of a static class that could benefit from such a procedure, such as when integration or unit tests are applied. I wonder if there is an...

How can I define generic exports without relying on the IOC libraries?

I am working on a library which needs to make use of the common service locator (http://commonservicelocator.codeplex.com/) to provide generic IOC support in order that we don't conflict with any consumers. Obviously I don't want to reference the IOC frameworks directly in my project but I'm unsure as to how to annotate the parts such t...