inversion-of-control

Ninject woes... 404 error problems

We are using the beloved Ninject+Ninject.Web.Mvc with MVC 2 and are running into some problems. Specifically dealing with 404 errors. We have a logging service that logs 500 errors and records them. Everything is chugging along just perfectly except for when we attempt to enter a non-existent controller. Instead of getting the desire...

Ninject Compact Framework

Anybody know where is the source of ninject compact framework? Any version is acceptable ...

How to instantiate objects of classes that have dependencies injected?

Let's say I have some class with dependency injected: public class SomeBusinessCaller { ILogger logger; public SomeBusinessCaller(ILogger logger) { this.logger = logger; } } My question is, how do I instantiate an object of that class? Let's say I have an implementation for this, called AppLogger. After I say ObjectFa...

IoC / Dependency Injection - please explain code versus XML

I understand basically how IoC frameworks work, however one thing I don't quite get is how code-based config is supposed to work. With XML I understand how you could add a new assembly to a deployed application, then change the config in XML to include it. If the application is already deployed (i.e., compiled in some form) then how can ...

Configuring IoC container from modules/plug-ins ?

Hi guys, i am in big dilema.. I am working on highly modular web app in ASP.NET MVC 2 (in fact, core will be super lightweight, all work on modules/plugins). I found MEF pretty useful for modules discovery, but i dont want to us it as IoC container. There is pretty good chance that I will need advanced features of "true" IoC container, s...

inject different implementations by logged User Role

public class TheController : Controller { IThe the; public TheController( IThe the) { //when User.IsInRole("r1") The1 should be injected else r2 this.the = the; } } public class The1 : IThe{} public class The2 : IThe{} //anybody knows a good way of doing this ? ...

IOC - Should util classes with static helper methods be wired up with IOC?

Hi, Just trying to still get my head around IOC principles. Q1: Static Methods - Should util classes with static helper methods be wired up with IOC? For example if I have a HttpUtils class with a number of static methods, should I be trying to pass it to other business logic classes via IOC? Follow on questions for this might be: ...

NHibernate + Sql Compact + IoC - Connection Managment

When working with NHibernate and Sql Compact in a Windows Form application I am wondering what is the best practice for managing connections. With SQL CE I have read that you should keep your connection open vs closing it as one would typically do with standard SQL. If that is the case and your using a IoC, would you make your repositori...

Has Unity got an equivalent to Castles Windsor's facility concept?

Castle Windsor facilities allow you to hook up some custom code that runs whenever components are registered. Does Unity have an equivalent? ...

StructureMap resolve dependency through injection instead of service location

In my project I register many ISerializers implementations with the assembly scanner. FWIW this is the code that registers my ISerializers Scan(scanner => { scanner.AssemblyContainingType<ISerializer>(); scanner.AddAllTypesOf<ISerializer>().NameBy(type => type.Name); scanner.WithDefaultConventions(); }); Which then correct...

StructureMap: How to register the same instance for all its interfaces

StructureMap newbie question. public class SomeClass: IInterface1, IInterface2 { } I would like the following test to pass: Assert.AreSameInstance( container.GetInstance<IInterface1>(), container.GetInstance<IInterface2>()); How would I do an explicit registration of this? I know in Castle Windsor I would do something lik...

Is it possible to use the Unity InterfaceInterceptor without using attributes?

All the examples I can find for the Unity InterfaceInterceptor require you to use Attributes to hook-up an ICallHandler to an artifact that you want to intercept. Is it possible to use an InterfaceInterceptor without needing to declare attributes so for example I can apply the interception to all classes? ...

How do I tell Castle Inversion of Control that I want a new instance of a singleton object without restarting the app?

At a certain point, during the running of my app, I want Castle.Windsor to release everything cached in memory. Is this impossible for a singleton object? ...

Approaches to use Repositories (w/ StructureMap) with AutoMapper?

Any idea how I can tell AutoMapper to resolve a TypeConverter constructor argument using StructureMap? ie. We have this: private class StringIdToContentProviderConverter : TypeConverter<string, ContentProvider> { private readonly IContentProviderRepository _repository; public StringIdToContentProviderConverter(ICon...

iBatis.net and IOC DI

Hey all, I'm using iBatis.net as my ORM and Structuremap for my IOC library. I'm currently trying to figure out how to get iBatis to use the IOC container to create objects instead of relying on the default constructor. Is there a way that anyone knows of to enhance iBatis in such a way? Currently as a work around I'm doing a hack of a...

Dependency injection: How to pass the injection container around?

(This question does not rely on a specific IoC framework, so the interfaces and types in my samples are meta-types. Just replace them with the appropriate types for your favorite IoC framework in your head.) In my main methods, I typically set up my container doing something like this: static void Main() { IInjector in = new Inject...

When to use an IOC container?

I'm trying to understand when I should use a container versus manually injecting dependencies. If I have an application that uses a 1-2 interfaces and only has 1-2 concrete implementations for each interface, I would lean towards just handling that myself. If I have a small application that uses 2-3 interfaces and each interface has ...

Castle Windsor and its own configuration file

I am using Castle Windsor for IoC, and have the configuration held in the web.config/app.config, using the following factory: public static TYPE Factory(string component) { var windsorContainer = new WindsorContainer(new XmlInterpreter()); var service = windsorContainer.Resolve<TYPE>(component); if (service ...

Instantiation failure and singleton-behaviour interaction [NInject1]

I have set up a NInject (using version 1.5) binding like this: Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx => { try { // create session factory, might fail because of database issues like wrong connection string } catch (Exception e) { throw new DatabaseException(e); } }).Using<Singleto...

SPRING: What is AOP, Dependency Injection and Inversion Of Control in Simple English

I have tried to understand AOP, Dependency Injection and Inversion of Control SPRING related concepts but I am having hard time understanding it. Can anyone explain this in simple English ? ...