ninject

Is this mbunit test really doing anything significant?

[Test] public void TestUserProfileInsert() { using (new TestBindingsWrapper("TestBindings", "", new TestModule())) { // Setup the mock the dataprovider MyMocks.MockDataProvider.Setup(x => x.InsertUserProfile(It.IsAny<IUserProfile>())).Returns(1); IUserProfile up = new UserProfile(); IUserProfileManager manager =...

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...

Can I use ninject to change implementations on the fly?

Using ninject, I know I can bind to a certain implementation, such that whenver I do: ISomeCache myCache = Ninject.Get(); It will load my concrete implementation that I binding ninject to. Say I store which concrete implementation I want to use in the database (web application), and when I change that in the admin panel it should on t...

Using the Ninject NLogModule Logger in global.asax

I'm using Ninject for DI in my asp.net application, so my Global class inherits from NinjectHttpApplication. In my CreateKernel(), I'm creating my custom modules and DI is working fine for me. However, I notice that there is a Logger property in the NinjectHttpApplication class, so I'm trying to use this in Application_Error whenever a...

Is Ninject Good for Production Applications?

Wondering if anyone has used Ninject in a production application? And what pros and cons should one be aware of? ...

Can you do conventions-based binding with StructureMap 2.5.3?

I find one of the best features of Ninject is conventions-based binding. eg. Bind<IConfigurationSource>().To<RemoteConfigurationSource>() .Only(When.Context.Target.Name.BeginsWith("remote")); Bind<IConfigurationSource>().To<LocalConfigurationSource>() .Only(When.Context.Target.Name.BeginsWith("local")); http://ninject.codeplex.com/Wi...

Looking for Ninject equivalent of StructureMap's ObjectFactory.GetInstance() method

I'm using Ninject in an MVC project and I've used the autoregistration features in Ninject.Mvc and have my bindings set up in my application class. However, I have a place where I want to create an instance separate from those bindings. In StructureMap, you can do var foo = ObjectFactory.GetInstance<IFoo>(); and it will resolve it for yo...

Resetting an IKernel in Ninject v1

I am experiencing an issue with v1 of Ninject and resetting the StandardKernel. I have a static object that I use to provide access to the kernel like so public static class ObjectFactory { private static IKernel _kernel = new StandardKernel(new CanceisModule()); // Resolve methods snipped for brevity public static void ...

Created a class that inherits from NinjectModule, where to load now?

After creating a class that inherits from NinjectModule, and overriding the Load() method with all my binding calls, where do I setup ninject in my asp.net web application? (MVC) Is it a httpmodule that I have to create? global.asax? ...

Ninject: How do I inject into a class library ?

To start I'm using Ninject 1.5. I have two projects: Web project and a Class library. My DI configuration is within the Web project. Within my class library I have the following defined: public interface ICacheService<T> { string Identifier { get; } T Get(); void Set( T objectToCache, TimeSpan...

C#, Ninject: Where do you put the kernel and your modules?

I'm creating a tiny C# application, which currently consists of a core assembly and a winforms assembly. I realize I probably don't really need Ninject in a small thing like this, but I would like to try it out. Anyways, to work with Ninject I have understood that you would write a set of modules, which maps class is returned and so on....

Where is the source code for NInject.Framework.Web?

I can't find it :( ...

Constructor injection with other, non-dependency, constructor arguments

I'm new to IOC containers, and I'm getting started with NInject. What do you if you want your constructor to have parameters that are not services and don't need to be instantiated by the IOC container? For example: public class Person { private readonly string _name; private readonly IPersonRepository _repository; public...

Can NInject load modules/assemblies on demand?

Are there facilities in NInject that will allow me to load services from other modules (assemblies) on demand like it's done in Unity? ...

How do you organise your NInject modules?

NInject's module architecture seems useful but I'm worried that it is going to get in a bit of a mess. How do you organise your modules? Which assembly do you keep them in and how do you decide what wirings go in which module? ...

Ninject 2, mvc and web forms

I'm using Ninject 2.0 in an asp.net app which is mvc and has web forms. This seems to be causing a problem with my Application class, as it inherits NinjectHttpApplication from Ninject.Web.Mvc But my master page is expecting a NinjectHttpApplication from Ninject.Web. Has anyone got mixed apps working with Ninject 2.0? ...

Error with AccountController and Ninject 2 and ASP.NET MVC 2 Preview 2

I'm using Ninject 2 and the Ninject.Web.MVC and using the NinjectHttpApplication Receiving the following error during the logon process: "A single instance of controller 'MySite.Controllers.AccountController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of...

Using the Ninject kernel as a Unit of Work object factory.

So I'm starting to use Ninject for dependency injection and I'm wondering what people think of using a kernel as an object factory for Unit of Work type objects like Linq2Sql Datacontexts. I would just inject them like normal dependencies, but this introduces some object lifetime issues I'd like to avoid. DataContexts are different tha...

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...

Auto-mock container: Rhino Mocks and NInject

Does anyone have an implementation lying around of an auto-mock container using Rhino Mocks and NInject? ...