[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 =...
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...
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...
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...
Wondering if anyone has used Ninject in a production application? And what pros and cons should one be aware of?
...
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...
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...
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 ...
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?
...
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...
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....
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...
Are there facilities in NInject that will allow me to load services from other modules (assemblies) on demand like it's done in Unity?
...
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?
...
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?
...
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...
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...
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...
Does anyone have an implementation lying around of an auto-mock container using Rhino Mocks and NInject?
...