ioc-container

Difference between "Inversion of Control", "Dependency inversion" and "Decoupling"

I'm reading theory about dependency inversion and decoupling and I can't see the difference between the two. Dependency inversion talks about decoupling functional components so that higher level components don't depend on lower level components. Decoupling talks about the same thing and how to achieve it. But then we have IoC Containe...

ASP.MVC and mvccontrib fluent test with IOC

I am trying to use the fluent test helpers to test an AbstractRestfulFluentController public class CustomerController : AbstractRestfulFluentController { private readonly IService<Customer> _customerService; private readonly IService<CustomerAddress> _addressService; public CustomerController(IService<Customer> customerServ...

castle windsor register a generic interface and retrieve all registered instances the inherit indirectly from it

I have the following structure - public interface IBaseInterface<T> { } public interface IChildInterface1<Class1> : IBaseInterface<Class1> { } public interface IChildInterface2<Class2> : IBaseInterface<Class2> { } public class ImplementationClass1 : IChildInterface1<Class1> { } public class ImplementationClass2 : IChildInterface2<Cl...

How to use an IoC Container?? I don't get it

Here's what I know so far: DI lets me build reusable, unit-testable components DI is verbose because it requires that I explicitly set the dependencies (via constructor or method. I still don't understand the interface injection though). This is why a container or a service locator is needed. Container is better than service locator be...

How to perform conditional binding in StructureMap from within a registry and without the use of generics?

I am familiar with Ninject and in Ninject you can do something similar to Bind<ICalendar>().To<MonthCalendar>().WhenInjectedInto(typeof(Roster)).InRequestScope(); I'm not sure how to perform something similar in StructureMap. I need to be able to do this dynamically from my own binding without the use of the generic StructureMap metho...

In Autofac how do I change the instance that is registered after Build has been called?

So lets say i have this code var builder = new ContainerBuilder(); builder.RegisterInstance(new MyType()); var container = builder.Build(); Then some time later I want to change the instance of MyType for all future resolves that are called on container. ...

Ninject binds to the wrong anonymous method when there is more than one method bound type

I am building a framework that I don't want to couple to a particular IOC container so have created a layer on top of Ninject / structuremap etc. I have a binding class that accepts a Func to allow binding to a method. For example public class Binding { public Type Source { get; set; } public Func<object> Method {get; set; } public...

IoC Container + Unit Testing

Is it ok to use a container to create the objects that are going to be tested? Or should I build them manually? ...

Dependency resolution as a seperate project ..How to?

hi, I am creating a new application using asp.net mvc, I m using munq IOC container as my dependency injection..The issue is i want to create a new project for dependency resolution where i can register all the controllers of mvc project and the repositories of infrastructure project..I have to add Dependency Resolution project as a refe...

How to reuse a transient dependency in same context with Castle Windsor DI container

If I have the following setup, how can I configure my container to use the same database, when objects are created in the same context public class Database { } public interface IRepository { Database Database { get; } } public interface IFooRepository : IRepository { } public interface IBarRepository : IRepository { } public class Foo...

IoC and ASP.NET MVC, where does it all begin?

I see "IoC" and "DI" mentioned pretty much everywhere for ASP.NET MVC. While I'm well aware of ... 'kind of' what these are, it's one of those almost ambiguous, amorphous floating concepts that seems to have either passed me by, or I'm just not looking in the right place. With the upcoming release of ASP.NET MVC 3.0, I'm seeing it even m...

Windsor WCF Facility factory ?

So I currently have a master DAO class ITrackingToolDAO that has all the Service Contracts for each of my business entities. public partial interface ITrackingToolDAO { void Open(string connectionString); void Close(); IBusinessFunctionDAO BusinessFunction { get; } IBusinessUnitDAO BusinessUnit { get; } IProgramBudg...

Unity: Am example of a bootstrapper file?

Hi there, does anyone have a good example of a boostrapper class i can see for reference.. I can't seem to find one anywhere, searched google but no luck. Searched the helpfile and no luck.. Any help really appreciated ...

Unity: How to registerType with a PARAMETER constructor?

Hi there, Can anyone help? How do i registertype with the container where the type doesn't have NO PARAMETER constructor. Infact my constructor accepts a string .. and i normally pass in a string that represents a Path. So when i do resolve it automatically creates the new type but passing in a string? Thanks in advance ...

Dependency injection into a Class annotation

Hi I'm trying to work out how to do the following: [CustomAnnotation(thisVariableShouldBeInjected)] public class MyClass { // Normal class stuff } Now the data annotation is decorating a WCF service class, which itself has constructor injection going on. Ideally I'd like to inject the annotation with a value using the Ninject IOC...

How to provide ASP.NET MVC2 master pages with a model indepdent of the controller

I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I...

Silverlight Constructor Injection into View Model + Design Mode

Hi all. Im trying to get to grips with writing testable ViewModels in Silverlight 4. Im currently using MVVM light. Im using AutoFac and the IoCContainer is doing its job fine. However to inject into the constructor of ViewModels, which are bound to Views I have this constructor chaining: public UserViewModel() : this(IoCContaine...

Unity Container Type Registration Quirk

Hi All, I'm trying to automatically register all reports in a unity container. All reports implement IReport and also have a Report() attribute which defines the title, description and unique key (so I can read these without instantiating a concrete class). So... I get the report types like this Public Shared Function GetClassesWhic...

Ninject, how to inject an object living in the session into my business class?

I have a profile object in session with profile information for the currently logged in user. I wand to be able to inject it into my business classes so I can do validation etc in them without having to pass it in the parameter list in every method. I have tried something like this in my ninject module: Profile profile = HttpContext.C...

Microsoft Unity. How to specify a certain parameter in constructor?

Hi, I'm using Microsoft Unity. I have an interface ICustomerService and its implementation CustomerService. I can register them for the Unity container using the following code: container.RegisterType<ICustomerService, CustomerService>(new TransientLifetimeManager()); If CustomerService has a certain parameter in its constructor (e.g...