ioc-container

Should one use DI on POCO classes when doing DDD?

Say I have a nice domain model, using (constructor) DI where needed. Now I want to be able to persist this model, so I start adding infrastructure(Entity Framework) to do this. What happens now is that the persistence framework should be able to initialize your types using your IoC container. Maybe this is possible, maybe not. Anyway, w...

Castle windsor : how to not to load all components in a castle windsor xml configuration when "Resolve" is called

I would like to use "strategy pattern" with 2 Web projects, my configuration file (and only with configuration file) : <?xml version="1.0"?> <configuration> <components> <!-- container ORM --> <component id="DALReseauContainer" type="ReseauRules.Db.BLL.DbReseauWorkingContextContainer, ReseauRules" ...

Is it better to create a singleton to access unity container or pass it through the application?

I am dipping my toe into using a IoC framework and I have choosen to use Unity. One of the things that I still don't fully understand is how to resolve objects deeper into the application. I suspect I just haven't had the light bulb on moment that will make it clear. So I am trying do something like the following in psuedo'ish code voi...

Strategy Design pattern with IOC containers - Ninject specifically.

I have a class which is going to need to use the strategy design pattern. At run time I am required to switch different algorithms in and out to see the effects on the performance of the application. The class in question currently takes four parameters in the constructor, each representing an algorithm. How using Ninject (or a general...

Ninject 2.0 - binding to a object that uses the same interface more than once?

Consider the following: public Something(IInterface concreteObjectOne, IInterface concreteObjectTwo) { this.concreteObjectOne = concreteObjectOne; this.concreteObjectTwo = concreteObjectTwo; } How do I set set this type of binding up with Ninject? I'd try Googling the term, but as I'm not sure what this is...

Any definitive guide for using Unity with an ASP.NET MVC site that hosts one or more web services?

I'm struggling to find a decent walkthrough for this issue, and was hoping that someone could shed some light on this... I've built an application using a ton of Unity and DI, and I need to pull a few components into a web site and run a WCF service now with them. host a WCF service for clients to connect to it instead of having it inclu...

Help me pick a Dependency Injection framework for .Net

Possible Duplicate: Which C#/.NET Dependency Injection frameworks are worth looking into? Yes I know this question has been asked many times, but the various frameworks keep evolving, so I would like a fresh answer on the subject. A few thoughts about the framework, they are not necessary black or white, but rather my prefere...

Dependency Injection Constructor Madness

I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this: public MyClass(Container con) for every class? What are the downsides? If I do this,...

Get Instance from StructureMap by Type Name

Is there any way to request an instance from the StructureMap ObjectFactory by the string name of the type? For example, it would be nice to do something like this: var thing = ObjectFactory.GetInstance("Thing"); The use case here is a messaging scenario in which the message is very generic and contains only the name of a task. A ha...

When is a Transient-scope object Deactivated in Ninject?

When an object in Ninject is bound with InTransientScope(), the object isn't placed into the cache, since it's, er, transient and not scoped to anything. When done with the object, I can call kernel.Release(obj); this passes through to the Cache where it retrieves the cached item and calls Pipeline.Deactivate using the cached entry. ...

Will IOC solve our problems?

Just trying to implement unit testing into a brownfield type system. Be aware i'm relatively new into the unit testing world. Its going to be a gradual migration of course because there are just so many areas of pain. The current problem i'm trying to solve is we followed a lot of bad practices from our VB6 days and in the conversion...

Windsor IHandlerSelector in RIA Services Visual Studio 2010 Beta2

Hi everybody! I want to implement multi tenancy using Windsor and i don't know how to handle this situation: i succesfully used this technique in plain ASP.NET MVC projects and thought incorporating in a RIA Services project would be similar. So i used IHandlerSelector, registered some components and wrote an ASP.NET MVC view to verify...

Generic <T> how cast ?

Hi, I have a "Product" base class, some other classes "ProductBookDetail","ProductDVDDetail" inherit from this class. I use a ProductService class to make operation on these classes. But, I have to do some check depending of the type (ISBN for Book, languages for DVD). I'd like to know the best way to cast "productDetail" value, I recei...

Autowire Annotation in Spring without using Component Scanning

Is it possible to autowire beans using the @Autowired annotation without using component scanning? ...

How does Unity.Resolve know which constructor to use?

Given a class with several constructors - how can I tell Resolve which constructor to use? Consider the following example class: public class Foo { public Foo() { } public Foo(IBar bar) { Bar = bar; } public Foo(string name, IBar bar) { Bar = bar; Name = name; } public IBar Bar ...

Need to have a single instance of a dependency container exist for a WCF service

The idea is to use DI container on my service contract implementation to instantiate my Business and Data classes. The reason I need to do it this way, is that I have one service contract that deals with different client requests. Each client request corresponds to different Business class ...

Using IoC and Dependency Injection, how do I wrap an existing implementation with a new layer of implementation without changing existing code so as not to violate the Open-Closed principle?

I'm trying to figure out how this would be done in practice, so as not to violate the Open Closed principle. Say I have a class called HttpFileDownloader that has one function that takes a url and downloads a file returning the html as a string. This class implements an IFileDownloader interface which just has the one function. So all...

Contructor parameters for dependent classes with Unity Framework

I just started using the Unity Application Block to try to decouple my classes and make it easier for unit testing. I ran into a problem though that I'm not sure how to get around. Looked through the documentation and did some Googling but I'm coming up dry. Here's the situation: I have a facade-type class which is a chat bot. It is a s...

Are we using IoC effectively?

So my company uses Castle Windsor IoC container, but in a way that feels "off": All the data types are registered in code, not the config file. All data types are hard-coded to use one interface implementation. In fact, for nearly all given interfaces, there is and will only ever be one implementation. All registered data types have a ...

WCF - StructureMap - Caching objects for the duration of the request only

So I already have a working implementation of StructureMap with the WCF service (including custom instance provider, behaviors, etc.) When I try to have an object that is instantiated only once per user request, I use the InstanceScope.HttpContext and it throws because the context is null. Do anyone have a proper way of doing that? ...