dependency-injection

Decorator Pattern with StrucutreMap (Via Config File)

Hi, A similar question was already answered but with c# code. I would like to know if this is possible with configuration: Here is the question, exactly samething I'm trying to do but with config. http://stackoverflow.com/questions/1443464/structuremap-and-the-decorator-pattern Thanks, Zerdush ...

Ninject 2.0: Passing different parameters depending on implementation

Hi everybody, I have just started to work with Ninject 2.0 with ASP.NET MVC 2. So, I have an interface IMongoRepository and class MongoRepository. MongoRepository receives a parameter string collection. Depending on the collection I want to use, I pass in a different value in parameter for MongoRepository. I hope I am phrasing this co...

Silverlight ViewModelLocator defined in app.xaml needs a reference to the DI container

I have a ViewModelLocator class that I am defining in app.xaml which is used by my views to databind to the correct ViewModel. DataContext="{Binding HomeViewModel, Source={StaticResource Locator}}" I am using Prism and Unity and my ViewModelLocator class needs a reference to an application level unity container. I wanted inject the I...

Determining missing dependencies statically when using dependency injection container

When using a dependency injection container, missing dependencies are detected when you execute resolve. This is at runtime. This article describes a partial solution. It would help simplify test, debug, and maintenance, but it still requires tests to be executed to validate your behavior (especially if you use the abstract factory su...

What resources did you find useful to understand Dependency Injection?

What book, blog, articles, webcast... did you find useful and relevant in order to quickly grasp Dependency Injection and understand how to use it effectively ? ...

Dependency Injection

public interface ITaskProvider { T GetTask<T>(); } In the implementation of ITaskprovider below, as you see the IUserTask and IIdentityTask is being injected from property instead of constructor. The reason is that Windsor automatically instantiates the injected properties on runtime when accessed so that i dont have to put all t...

Autoloading Symfony classes in Zend_Framework

Hello, How to autoload Symfony classes in the app based on Zend Framework? Can I push some kind of Symfony autoloader to the Zend's Autoloader? I need to use some of the components like output escaper or dependency injection classes. ...

How to use dependency injection in Zend Framework?

Currently I am trying to learn the Zend Framework and therefore I bought the book "Zend Framework in Action". In chapter 3, a basic model and controller is introduced along with unit tests for both of them. The basic controller looks like this: class IndexController extends Zend_Controller_Action { public function indexAction() ...

SimpleServiceLocator: Why is automatic constructor injection not supported for singletons?

I've been experimenting with the SimpleServiceLocator, and I like it quite a bit, but there's one thing that I'm really frustrated by--you can't use automatic constructor injection for singletons. To make matters worse, you can't even use automatic constructor injection for its dependencies. You have to create the singleton object, all i...

How to add new object to track in Ninject after Application_Started?

Is it possible to add a new object that Ninject should be responsible for (lifetime, injection etc.) in an ASP.NET application after the Application_Started event is fired? My application needs to dynamically designate objects that should be tracked well after the application is started ...

Castle Windsor 2.5 Breaking Changes

I have code that was previously adding ExtendedProperties to components like component.ExtendedProperties( new { prop = someObject }); This method is no longer available and the constructor for Property is marked internal. Is there a new way of doing this for v2.5? Specifically, I have a custom ComponentActivator that needs some in...

How to instantiate a MEF exported object using Ninject?

My application is using MEF to export some classes from an external assembly. These classes are setup for constructor injection. The issue I am facing is that MEF is attempting to instantiate the classes when I try to access them. Is there a way to have Ninject take care of the instantiation of the class? IEnumerable<Lazy<IMyInterface>...

Dependency Inject with Ninject 2.0

A little question regarding Ninject. I use a WCF 'duplex channel' to communicate with a service. The channel is defined as an interface, lets call it IMyChannel for simplicity. To instantiate a channel we use DuplexChannelFactory<IMyChannel> object's CreateChannel() method. So far I have manage to bind the factory class with this. Bin...

Constructor Injection of an ObjectContext using Unity/Prism/MVVM

Hi there, I develop an application using WPF with MVVM pattern and Prism. The views are added to the ModuleCatalog and the viewmodels are registered to a unity container. For that I'm using a Bootstrapper which is responsible creating the shell, configuring the unity container and the module catalog. The question is now, how injecting m...

WPF/MVVMDo I need a dependency Injection tool like Unity/LightCore when using a ViewModelLocator

Hello, I would like to use a ViewModelLocator and I would like to know wether it is a basic requirement using a DI framework to make a ViewModelLocator possible? ...

Dependency Injection (Constructor) with WebForms?

Is this possible with ASP.NET 4.0? In 3.5 it was not. If it still is not possible has anyone tried injection with a framework like LinFu? Update I'm specifically asking about constructor inject in ASP.Net webfroms. In 3.5 it was not possible. ...

How to learn Autofac fast for Windows development?

I'm about to start a project where the IoC being used is AutoFac - at a new company. I have no prior experience with DI/IoC and want to get up to speed on this so I don't look toooo unintelligent. This will be for a WPF application (which again I'm not too cluey about but that will be OK) What are some good resources I could use to lear...

In PHP Dependency Injection, do I need to "require_once" the php file where the dependency is defined?

Taking Fabien Potencier's example: class User { function __construct($storage) { $this->storage = $storage; } // ... } Assuming the Storage class is defined in a different php file (say, storage.php), do I need to include it in this file where the injection is done via a require_once? Thanks, JDelage ...

How do I resolve an array with Unity and pass a parameter to one of the items in the array?

Hi there, So here's my factory method which takes a parameter... container.RegisterInstance<Func<IProductInstance, IQuantityModifier[]>>( instance => container.Resolve<IQuantityModifier[]>()); Now one of the items returned by the array takes the IProductInsance parameter in its constructor. I can't figure out ...

What do you look for in a dependency to determine if it should be an injected dependency?

I am having difficult figuring out when a dependency should be injected. Let's just work with a simple example from my project: class CompanyDetailProvider : ICompanyDetailProvider { private readonly FilePathProvider provider; public CompanyDetailProvider(FilePathProvider provider) { this.provider = provider; } ...