ninject

Ninject equivalent of Unity RegisterInstance method

Does Ninject have and equivalent method for unity's registerinstance. I want to create a mock object and register it. Thanks ...

Ninject kernel binding overrides

I'm just wondering what the best practice is for rewiring the bindings in a kernel. I have a class with a kernel and a private class module with the default production bindings. For tests I want to override these bindings so I can swap in my Test Doubles / Mocks objects. does MyClass.Kernel.Load(new InlineModule(m=> m.Bind<IDepend>(...

Ninject, ASP.NET and Custom Controls

Hey guys, I'm currently using ASP.NET (standard, not MVC) and I'm using Ninject as my IOC container. I'm already using it to inject dependencies into my pages, however, I was wondering if there was a way to inject dependencies into my custom controls? If not, I'll get underway extending Ninject :) ...

How to apply dependency injection to UserControl views while keeping Designer happy?

public class StatisticsViewPresenter { private IStatisticsView view; private Statistics statsModel; public StatisticsViewPresenter(IStatisticsView view, Statistics statsModel) { this.view = view; this.statsModel = statsModel; } } I don't use events (but am willing to if it can solve my problem), so ...

Ninject - how and when to inject

Hi, I'm a newbie when it comes to DI and ninject and I'm struggling a bit about when the actual injection should happen and how to start the binding. I'm using it already in my web application and it working fine there, but now I want to use injection in a class library. Say I have a class like this: public class TestClass { ...

Ninject and Singleton

My application uses NHibernate with a session per request implementation. I have a core library that provides a thread safe singleton for getting access to the current nhibernate session. That singleton is leveraged from the web application in the BeginRequest and EndRequest events to ensure the opening and closing of the session wit...

Ninject 2 configuration sample for class library projects

I'm gonna use Ninject 2.0 in a project and looking for a good sample on how to configure it for a class library case. Many samples are available for WebForms and ASP.NET MVC but in my case I want to inject a Repository in my DataAccess project to Services project (both are class libraries) and I don't need to inject anything into my Web ...

Ninject AOP - getting method parameters from intercepted method

Hi. Does anyone know of a way to get hold of the intercepted parameters sent into a method. For instance... You have an Update method inside a CustomerService like this.. Update(Customer c) ..and you want to get hold of the Customer object sent into the service. Does it come out of the box in any way or do I have to do anything else e...

ASP.NET MVC - Ninject 2.0 Activation Error

I just started working with dependency injection for the first time and I am using as Ninject 2.0 as my IoC container in an ASP.NET MVC 2 website and I'm hitting an activation error that I am not sure how to react to. I am sure it's simple so hopefully someone can point me in the right direction without too much thought. I have a proper...

With.Parameters.ConstructorArgument with ninject 2.0

How to use this funcionality in ninject 2.0? MyType obj = kernel.Get<MyType>(With.Parameters.ConstructorArgument("foo","bar")); The "With" isn't there :( ...

IAuthorizationFilter + Ninject2

I'm currently using Ninject2 to bind the various services and repositories in my MVC app. That part seems to be working just fine. Now I'd like to also bind my own class to IAuthorizationFilter and all actions that have the attribute set. I've created a class that inherits from AuthorizationFilter and Implements IAuthorizationFilter. ...

What is the equivalent of Container.GetAllInstances<T> in NInject?

I'm building a message broker with NInject, and I need to find all instances in the container that implement Consumes, an interface that marks the class as being able to consume a particular message type. Is this scenario supported? ...

Does ninject-contrib support Silverlight?

I'm building a Silverlight application with Prism, and we'd like to use NInject. I've downloaded ninject-contrib to use their NInject bootstrapper, but it doesn't appear to build a Silverlight assembly. I compiled it myself to Silverlight, but it crashes Visual Studio. Has anyone already ported ninject-contrib to Silverlight success...

Is ninject considered a container?

Hi, I was talking with someone and mentioned I was learning IOC and was using ninject to get the feel for things. He asked me what container I was using? I told him ninject. Having no idea what he was referring to, I know there is castle windsor products that are more popular. Can someone clear this up for me? What am I missing here...

How do you make a Ninject Provider when the constructor of type is not known?

I decided to try to conjure up a container assembly to interact with FubuMVC. Well the cool part is that it pass all the test that the FubuMVC.Container.StructureMap assembly does. However, when I dropped it into the FubuSample. I received an activation error. The error is because in the provider for the behaviors I'm only calling a par...

Is Ninject MVC supposed to work with MVC 2 Preview?

I am running a MVC 2 Preview and this is my first time trying to use Ninject2 MVC There error that I am continently getting is: An error occurred when trying to create a controller of type 'MyMVC.Controllers.EventsController'. Make sure that the controller has a parameterless public constructor. What I have in my Global.cs is this: pu...

Using Ninject With Entity Framework

I have a repository Class which takes in a ObjectContext called "TestDB". I when I launch my web application i'm getting a "Unable to load the specified metadate resource", almost like its not picking up the connection settings from my web.config file anymore. Here is a snippet of my code. [Inject] public SqlCatelogRepository(){ _da...

Can I get a concrete type from an interface instance with Ninject?

I have contracts for functionality in my repository that are implemented with linq-to-sql. // IEvent was extracted from the generated linq-to-sql class public partial class Event : IEvent { } public class EventRepository : IEventRepository { public void Add(IEvent e) { db.Events.InsertOnSubmit(e); db.SubmitCha...

Where should I do dependency injection with Ninject 2?

I have a solution with two relevant (to this question) projects, and a few others; Class library with functionality used by several other projects. ASP.NET MVC application. My question is basically where I should do IoC with Ninject 2, considering... The class library needs some DI love, among other things in the repository classes...

DI with Ninject in a Class Library

I'm successfully using Ninject in my web applications by deriving my Global from NinjectHttpApplication and using the NinjectHttpModule in my web.config What I want to do now is us DI in one of my class libraries and I don't know how to go about this. I have the following dummy class: /// <summary> /// Testing Ninject DI in a clas...