dependency-injection

I am looking for a simple yet practical and robust IOC\DI framework for .net

I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about: Ninject Castle Windsor StructureMap Which would present a moderate learning curve without losing flexibility? and another question - where is the correct place to put the configuration?...

Anybody using Qi4J

I was reading an InfoQ article on Composite Oriented Programming earlier on: http://www.infoq.com/articles/Composite-Programming-Qi4j I was interested in finding out whether anybody is currently using (or has used) the Qi4j framework at all? How does it compares to using a traditional dependency injection framework such as Spring for ...

Specifying a default Unity type mapping for a generic interface and class pair

We're using constructor-based dependency injection, AutoMapper and Unity on a codebase. We have wrapped AutoMapper with a generic interface... public interface IMapper<TSource, TDestination> { TDestination Map(TSource source); } And a class that implements this interface... public class AutomaticMapper<TSource, TDestination> : I...

Composing a Controller class with Dependency Injection in PHP

How to solve the problem of composing a Controller class in PHP, which should be: easily testable by employing Dependency Injection, provide shared objects for end programmer provide a way to load new user libraries Look down, for controller instantiation with a Dependency injection framework The problem is, that derived Controll...

Quartz.Net and dependancy injection or calling a job from external dll at runtime

I am trying to evaluate Quartz.Net. I tested it with adding a class which implemented IJob in the executing assembly and it worked. Now I want to develop an Job Scheduler in which I can add jobs at runtime. How to proceed. Edit: If it seems subjective I have following specific question. How to add external class/dll which are unkno...

Comparing Castle Windsor, Unity and StructureMap

In a follow up to Krzysztof’s statement that Windsor does a lot more than other IoC’s, I wanted to understand how these IoC’s stack up against each other and the benefits/additional facilities that castle Windsor provides. Are there any comparisons? Can someone help me understand the additional features that Castle Windsor provides ov...

Should I put my ThreadLocals in a spring-injected singleton?

Several people (eg at serverside http://www.theserverside.com/news/thread.tss?thread_id=41473) suggest that using ThreadLocal objects is as bad as using global variables. I imagine this is true if you make them public static variables. The problem then is that it can be hard to tell where it is used, where it's changed, etc. In my sprin...

LightSpeed with IoC/Dependency Injection using Repository Pattern

Does anyone have an example of using LightSpeed with the Repository Pattern using interfaces and dependency injection? ...

Unity & WPF - injecting a DataContext via property injection to a child control

I followed Jason Dollinger's MVVM sample from Lab49 to learn the basics of using Unity with an MVVM WPF application. I constructed a simple sample following his basic architecture, using property injection and the Dependency attribute to inject viewmodels into the views. My sample has a main window with a child user control created in ...

Injecting dependencies into tests

Usually when using dependency injection, unit (and other) tests are responsible for creating/mocking dependencies of the system-under-test and injecting them. However, sometimes the test itself has dependencies, or needs to inject dependencies into the SUT that it can't itself create. For example, when testing classes which interact wit...

How to use DataTemplates in Prism

I have been using Prism for a while now and enjoy how much easier it is to decouple my modules. This works especially great for views and view models since you can inject the view models via interfaces and the views via the region manager. Unfortunately this only works when my views are full blown user controls unless I'm missing somet...

How do I use a Type Discriminator field in my DTO to instantiate the appropriate domain object with DI?

I am looking for suggestions on how to map a single DTO class with a type discriminator to multiple domain classes. I have my DTO: public class FooData { public Guid Id { get; set; } public string Name { get; set; } public string TypeDiscrim { get; set; } } public class FooDataRepository { public List<FooData> GetAll()...

How do i get ninject 2.0 working with asp.net mvc 2?

Hello, i am using:- asp.net mvc rc 2 Ninject and ninject asp.net mvc extension (http://github.com/enkari/ninject.web.mvc) i keep getting the 'No parameterless constructor defined for this object.' for my AccountController. The AccountController is injected with Services. The bindings for these services are defined in the ServiceModu...

How can I use "Dependency Injection" in simple php functions, and should I bother?

I hear people talking about dependency injection and the benefit of it all the time, but I don't really understand it. I'm wondering if it's a solution to the "I pass database connections as arguments all the time" problem. I tried reading wikipedia's entry on it, but the example is written in Java so I don't solidly understand the dif...

Dependency injection when you have no control over instantiation and usage

How is it done? I have a Model class that is the parent to many sub-classes, and that Model depends on a database connection and a caching mechanism. Now, this is where it starts getting troublesome: I have no control over how each object gets instantiated or used, but I have control over methods that get used by the sub-classes. Curr...

Immutable classes and unity application block

I am writing a small utility for myself so whilst I am using Unity currently, I can change to a different IoC container if it will allow me to get around this problem. I want to create a class that is given some data when it is created, but is immutable after that, normally I would do this with: class SomeItem { public SomeItem(str...

Dependecy Injection: How To Overcome Cyclic Dependencies

Hello guys, Thanks for reading. I'm using Unity framework to implement dependency injection in my app (ASP.Net MVC). Sometimes there are some cyclic dependencies among services that I want to avoid. So I'm looking for solutions : ) My case well lets imagine 3 services ServiceSally, ServiceJoe, ServiceJudy ServiceSally depends on S...

Dependency Injection, Unit Testing, and Information Hiding

Suppose you have a class Foo with private member of type Bar. You don't want users to know that Foo's implementation contains a Bar and you don't want users to be able to create their own Bar and pass it through Foo's constructor, any other method, or a configuration file. Edit: Bar is also problematic in that it accesses resources ...

Hide class dependencies from end user instantiating it (PHP)

Hi, My situation is essentially this: I have a class called Foo which has dependencies A and B, all of which are internal to a library. Instances of Foo will be created by user of the library, and they should not require knowledge of the dependencies. Internally of course I would like Foo to remain decoupled from the concrete implement...

Action delegate dependency resolution using Castle Windsor

I have a class with a constructor that looks like this: public TimedWorker(int timerInterval, Action execute, ILogger logger) I am using the Castle Windsor fluent configuration and whilst the config below works, I am concerned about the way I am resolving Action. Is there a better way so that I am not always resolving the action deleg...