ninject

How to set up SubSonic ActiveRecord Repository in the ASP.NET MVC Starter Site

I would like to setup ActiveRecord iSession with Ninject IoC just like SubSonicSimple is done. http://mvcstarter.codeplex.com/ Pls help ;) ...

Strategy for wiring up events?

I'm using Ninject (1.5 ... soon to be 2) and I'm curious how other people use Ninject or other IoC containers to help wire up events to objects? It seems to me in my code that I'm doing it herky-jerky all over the place and would love some advice on how to clean it up a bit. What are people doing out there to manage this? ...

Prevent Ninject from calling Initialize multiple times when binding to several interfaces

Hi We have a concrete singleton service which implements Ninject.IInitializable and 2 interfaces. Problem is that services Initialize-methdod is called 2 times, when only one is desired. We are using .NET 3.5 and Ninject 2.0.0.0. Is there a pattern in Ninject prevent this from happening. Neither of the interfaces implement Ninject.IIn...

Issue intercepting property in Silverlight application

I am using Ninject as DI container in a Silverlight application. Now I am extending the application to support interception and started integrating DynamicProxy2 extension for Ninject. I am trying to intercept call to properties on a ViewModel and ending up getting following exception: “Attempt to access the method failed: System.Reflec...

Ninject : ninject.web - How to apply on a regular ASP.Net Web (!MVC)

What I am looking is something similar to the below (http://github.com/ninject/ninject.web.mvc): README.markdown This extension allows integration between the Ninject core and ASP.NET MVC projects. To use it, just make your HttpApplication (typically in Global.asax.cs) extend NinjectHttpApplication: public class YourWebApplication ...

How to stub ninject's IKernel using Rhino Mocks?

var mocks = new MockRepository(); var access = new Access(); access.ShowRepository = _mocks.Stub<IShowRepository>(); access.ShowRepository.Stub(x => x.GetShows()).Return(new List<Show>()); var kernel =_mocks.Stub<IKernel>(); kernel.Stub(x => x.Get<Access>()).Return(access); This throws an ArgumentNullException: Message: Value canno...

Inject Array of Interfaces in Ninject

Consider the following code. public interface IFoo { } public class Bar { public Bar(IFoo[] foos) { } } public class MyModule : NinjectModule { public override void Load() { Bind<IFoo[]>().ToConstant(new IFoo[0]); // ToConstant() is just an example } } public class Program { private static void ...

ASP.Net MVC, Ninject IOC.

I'm using Ninject to do some dependancy injection. (Mainly for the DAL), my project consists of 3 aspects and are as follows, Project.Lib (Everything database, services and anythign else that is logic) Project.Admin (Administration) Project.Web (Front end what the user see's) Now, each of my controllers within my projects inherit fro...

Create an instance of ISession per ViewModel

Hello all, here is my problem: I'm building a desktop application, with the following tools: Caliburn Ninject NHibernate All my view models and repositories are instanciated with Ninject. My repositories all need an ISession in their constructor. I'd like to follow ayende's advice concerning the ViewModels: each ViewModel opens a n...

StructureMap to Ninject rules

How to write this StructureMap line in Ninject ForRequestedType<HttpContextBase>() .TheDefault.Is.ConstructedBy(x => new HttpContextWrapper(HttpContext.Current)); ? ...

Ninject with ASP.Net webforms and MVC

I want to use Ninject in a project which combines ASP.Net webforms and ASP.Net MVC. I'm using Ninject 2, but when I use NinjectHttpApplication from Ninject.Web.Mvc it complains when I use somethings like a PageBase that the Kernel is not created. I have the following in the Global.asax and am unsure what to add. public class MvcApplic...

Ninject and repository pattern with interfaces

This is the interfaces/class structure I have now: BaseContentObject abstract class public abstract class BaseContentObject : IEquatable<BaseContentObject> { ... } Page concrete class public class Page : BaseContentObject { ... } Repository interface public interface IContentRepository<T> { // common methods for all c...

Dependency injection inside ASP.NET MVC custom model binders and filters

This is my custom model binder code for the BaseContentObject class: public class BaseContentObjectCommonPropertiesBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (controllerContext == null) { throw new Argume...

Avoiding circular dependencies in XNA using Ninject 2.0

I have been using Ninject as the IOC for an XNA project, and was wanting to migrate it to Ninject 2.0. However, XNA is not dependency injection friendly, as certain classes must be instantiated in the constructor of the game class, but must pass the game class to their constructors as well. For example: public MyGame () { this.graph...

Binding singleton to multiple services in Ninject.

Hi, I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types. I'm using the latest release of Ninject 2 for Compact Framework and the exact issue I'm havin...

Ninject Intercept

from what dll can i get the extension of Intercept ? I've added Ninject.Extensions.Interception from http://github.com/danielmarbach/ninject.extensions.interception No luck there. Is there some sample working ? What I need is to make an interceptor that will path through from WcfClient to WcfServer a different functions with different...

Dependency injection and mock framework for .net

I am trying to set up expectations on methods of a mocked object in Moq. At the same time, using Ninject, I try to have the kernel return my set up mock whenever a caller wants the corresponding interface. For more clarity, here's some pseudocode Class Car { Void buildChassis() { Engine = ObjectBuilder.get<Iengine>() ...

Property Injection in Base Controller using Ninject 2

I have the following code in my Global.aspx protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); } protected override IKernel CreateKernel() { return new StandardKernel(new ServiceModule()); } ...

How to register types that implement a specific interface on a ninject container

How can I register on a ninject container all the types that implement a specific interface? It's worth saying that I'm using Webforms so IBuildManager is not available. I'd like to achieve something I saw on a MVC application with unity which goes like this: private static void RegisterRepositories(IBuildManager buildManager, IUnityCon...

System.NotSupportedException: Parent does not have a default constructor. The default constructor must be explicitly defined.

I'm working with Ninject 2.0.2 Ninject.Extensions.Interception with DynamicProxy2 Castle.Core Castle.DynamicProxy2 The injection worked fine. Then I inserted the wcf between controller and bl layers. For interaction between the layers I've used the Ninject.Extensions.Interception of Ian Davis. I've used the DynamicProxy2 for creatin...