dependency-injection

What is the best documented IOC framework for .net?

I am looking for the IOC/DI framework with the best documentation which would it be? ...

Spring - StackOverflowError in Bean creation

Hello, I am getting the following error: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:203) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExe...

Castle Windsor Dependency Injection with Multiple Concrete Implementations

Is there a method for Castle Windsor to inject multiple concrete implementations of a single interface into a constructor? I want to do something like this: class Some { public Some(IService[] services) { services.Each(s => s.DoSomething(this)); } } Note, at this level I do not have access to the IWindsorContainer and ...

DI with Ninject in a Class Library

I'm successfully using Ninject in my web applications by deriving my Global from NinjectHttpApplication and using the NinjectHttpModule in my web.config What I want to do now is us DI in one of my class libraries and I don't know how to go about this. I have the following dummy class: /// <summary> /// Testing Ninject DI in a clas...

Using Guice with circular dependencies

Consider this simple example. Class A { B b; A() { this.b = new B(this); } } In this example instance A knows about instance B, and instance B knows about instance A. My question is: how to instantiate instance A with Guice, i.e. how to make Guice take care of this complex circle dependencies? ...

Other than testing, how is Dependency Injection any better than static classes/methods?

Other than testability, what's the big advantage of utilizing D.I. (and I'm not talking about a D.I. framework or IoC) over static classes? Particularly for an application where you know a service won't be swapped out. In one of our c# application, our team is utilizing Dependency Injection in the web web GUI, the service layer, and th...

Ninject 2.0 Constructor parameter - how to set when default constructor is also present?

I'm new to IOC containers and learning Ninject. I've using version 2.0, freshly downloaded from Github. I'm trying to set a string parameter on a constructor when a default constructor is also present. I've been stepping through the Ninject source but I'm insufficiently familiar with the patterns being used to easily pinpoint what I...

how to inject dependency into a custom control

Hi, I am using Dependency Injection to Inject interface into my few views. One of the requirement I need to Inject the interface into the custom control. I have tried using ServiceDependency attribute to inject interface , but it doesn't work. public interface ISearchService { void CustomizeLayout(ColumnCollection collection); } ISe...

Best way to use StructureMap to implement Strategy pattern

My web app has some slight variations in business logic and presentation logic depending on the type of user that is logged in. It seems like getting variations by injecting different concrete classes based on the user type is a good fit for DI. So I'm wondering what features of StructureMap I should use to achieve this (or if I'm way of...

Does an abstract class work with StructureMap like an interface does?

I am a big fan of StructureMap and use it in just about everything I do. I have only ever used it with interfaces though. I was wondering if anyone had any experience using with abstract classes? or...does it not support that type of wiring? If you got this to work can you post an example? Thanks! ...

Dependency injection through constructors or property setters?

Hi, I hope this isn't a duplicate. I did a search but there are a lot of dependency injection posts and I couldn't find any needles in the haystack. So here's my question. I'm refactoring a class and adding a new dependency to it. The class is currently taking its existing dependencies in the constructor. So for consistency, I add the p...

Unity and delegate

Hi I'm using the Unity dependency injection framework. I have two classes, that each take the same delegate parameter in the constructor. Each class should get a different method when resolved. Can I set this up without using attributes ? If not how would you do it with attributes? ...

Dependency Injection as a Language Feature?

Are there any existing modern-day programming languages that explicitly have dependency injection as a language feature, and if so, are there any examples of how such programming languages use their syntax to separate program dependencies from their concrete implementations? (Please Note: I'm not looking for an DI/IOC framework--I'm act...

how do I configure autowire in spring

how do I configure autowire in spring ...

Injecting a resource into an abstract class

I have an abstract class, Shape, and I have a Canvas object that the Shape uses to set its position. I need to make sure that all Shapes have a Canvas object, preferably a Canvas object that is the same one across all shapes. I have thought of a couple of options: Add a canvas parameter to the Shape constructors (there are many) Havin...

Spring DI, Domain Model & best practices

Is it a good idea to not inject Domain Models in Spring. It saves some XML, and what is the use of injecting domain model anyway. For services and DAO, I want to decouple so I use DI, but Domain Model usually flows all the way from Web to DAO - sort of a vertical layer running through the horizontals. What do you think? Good or bad? Ar...

Castle Windsor (or other DI) - creating object based on parameter

Hi there! I am pretty new to the whole DI/IoC thing, so bear with me... I have this kind of setting: interface IA interface IB interface IC abstract class A : IA class B : A, IB class C : A, IC interface IX interface IY interface IZ abstract class X : IX class Y : X, IY class Z : X, IZ B and C's constructors look like this: public...

Autofac with Open Generics and Type Specified at Runtime

The documentation states that Autofac supports open generics and I am able to register and resolve in a basic case like so: Registration: builder.RegisterGeneric(typeof(PassThroughFlattener<>)) .As(typeof(IFlattener<>)) .ContainerScoped(); Resolve: var flattener = _container.Resolve<IFlattener<Address>>(); The above ...

Unit Testing File I/O

Reading through the existing unit testing related threads here on Stack Overflow, I couldn't find one with a clear answer about how to unit test file I/O operations. I have only recently started looking into unit testing, having been previously aware of the advantages but having difficulty getting used to writing tests first. I have set ...

spring: a bean that receives a list of Classes

I want to define in my Spring XML context a bean that has a property of the type List of classes: i.e. List<Class<?>> classes How do I send that bean a number of classes, say java.lang.String and java.lang.Integer? The list needs not be reusable, i.e. I will not refer to it in another bean. ...