ioc-container

UNITY: passing in a new datacontext each time?

Hi there, I am trying to use unity to automatically inject a datacontext on my repository using a new instance each time.., my idea is the ensure that each time a new datacontext is injected Currently its failing on creating the repository, i think it can't resolve MyDataContext Before creating a constructor on "the repository" (see b...

Project Windsor - Repository Extending DataContext

Before I begin I will say this: I have to extend DataContext in my repository because I'm calling stored procedures and ExecuteMethodCall is only available internally. Many people don't seem to know this, so please don't say "just don't extend DataContext". I've just started using Windsor as my IoC container. My controller happily doe...

Spring.Net IoC: alternative to using configuration metadata XML

I'm trying to get a grasp of using spring.net ioc to suit my purpose. What options to using xml configuration (metadata file) are available in spring.net ioc. i.e. i don't want to use the following: <object name="MyMovieFinder" type="Spring.Examples.MovieFinder.SimpleMovieFinder, Spring.Examples.MovieFinder"/> </object> ...

Strategy Pattern and Dependency Injection using Unity

I am finally getting my feet wet with Dependency Injection (long overdue); I got started playing with Unity and run into an issue with the strategy pattern. I can use the container to return to me specific implementations of a strategy based on a name, but what I don't see is how I am supposed to get the right strategy in the context. Le...

Using IoC to resolve dynamically loaded types

I've written a program using Domain Driven Design in .NET 2.0 and I'm trying to implement a plugin framework for it. I've implemented several types of plugins: Domain Plugin A domain aggregate composed of one or more domain classes One or more View/Presenter pairs to display instances of the aggregate An import/export service specif...

IoC Containers and Domain Driven Design

I've been searching for guidance for using IoC containers in domain driven design. Evan's book unfortunately doesn't touch on the subject. The only substantial guidelines I could find on the internet is here. Many of Malovic's points are common sense but I'm concerned about a few of them. He suggests that IoC container's should be reser...

Spring's IOC with annotations is confusing for a Guice guy. Help to enlighten me

I came into IOC via Google Guice. And now I've been forced to use Spring 2.5.6 at work & I am lost because Spring is quite complicated. Here are some questions after reading bits of the spring docs: What is the difference between @Service, @Controller and @Component ? If I just want to auto wire my objects like Guice, do I need to be ...

Should I encapsulate my IoC container?

I'm trying to decide whether or not it makes sense to go through the extra effort to encapsulate my IoC container. Experience tells me that I should put a layer of encapsulation between my apps and any third-party component. I just don't know if this is bordering on overkill. I can think of situations where I might want to switch cont...

IoC container object scoping

I am interested in implementing an IoC container in my project but I haven't seen an example out there that does what I need. Here is the situation, my application is built in WPF and uses the MVVM pattern to create a player for an infrared video format. In this format, each video is actually made up of multiple "subframes" (think of i...

Is it right to use IoC for the extensibility of my entities or domain model?

Hi Everyone, I've came across a dilemma which I think is worth discussing here. I have a set of domain objects (you can also call them entities, if you like), which get some data from a separate DAL which is resolved with an IoC. I was thinking about making my system very extensible, and I'm wandering if it is right to also resolve th...

Does MS PnP Unity Scan for Assemblies Like StructureMap?

In Using StructureMap 2.5 to scan all assemblies in a folder, we can see that StructureMap uses AssembliesFromPath() to explicitly look for types to resolve. What is the equivalent of this in Microsoft Unity? Because Unity is such a generic term, searching for documents about this online is not that easy. Update: Unity has something cal...

How to Inject Open Connections with an IoC

First, my scenario. I have a service, BillingService, has a constructor like this: BillingService(IInstallmentService, IBillingRepository) The InstallmentService has a constructor that looks like this InstallmentService(IBillingRepository, IInstallmentCalculator) My Billing service is an application service and the methods will coor...

how to mock container.Resolve<Type>()

i have a something like this public class HomeController { public ActionResult Index() { var x = Container.Resolve<IOrganisationService>(); } } when unit testing i get a null reference exception when the container tries to resolve anybody knows how do to mock Container.Resolve() ? ...

Should controller lifestyle always be transient in Windsor configuration for ASP.NET MVC?

I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which ...

Ninject And Connection Strings

I am very new to Ninject and am trying Ninject 2 with MVC and Linq. I have a SqlProductRepository class and all I want to know is what's the best way of passing the connectionstring in the constructor if I am injecting the Repository object in the controller. public class SqlProductRepository:IProductRepository { private Table<Pro...

Windsor Castle IoC, how to register IBaseService<TObject> to BaseService<TObject, TRepository>

I have something like this: public interface IBaseService<TObject> public class BaseService<TObject, TRepository> : IBaseService<TObject> where TRepository : IRepository<TObject> I need to register BaseService To IBaseService (the IRepository<> is registered) ...

Using StructureMap to Configure Prism

I'm using Prism and the Unity IoC container that comes along with Prism. However, I'd like to use a different IoC container if that's doable. So; is it? Preferrably I'd like to use StructureMap. Note that I'm not yet familiar with StructureMap, but based on several recommendations I'd like to give it a try. The question is really how t...

Why shouldn't I use Unity?

I'm using the Unity IoC container. It really wasn't a decision I made, it just came with Prism, and I've just stuck with it. I've never used any other IoC frameworks, and I must admit I'm quite happy with Unity. However, the satisfaction may come from ignorance as I don't really know what the other frameworks have got to offer. I keep h...

Where to keep things like connectionstrings in an IoC pattern?

In my everlasting quest to suck less I'm currently checking out mvc Turbine to do the IoC dirty work. I'm using the mvc Turbine nerd dinner example as a lead and things look rather logical thus far. Although I'm refering to the turbine project here, I'm guessing the philosophy behind it is something general to the pattern Safe for some r...

Castle Windsor: UsingFactoryMethod can't instantiate with a weird error

When I use this registration: container.Register( Component .For<IFooFactory>() .ImplementedBy<FooFactory>(), Component .For<IFoo>() .UsingFactoryMethod(kernel => kernel.Resolve<IFooFactory>().CreateFoo()) ); I get this exception: Castle.MicroKernel.ComponentRegistrationException: Type MyNam...