ninject.web.mvc

bind to property always return null

馋奶兔 提交于 2019-12-25 09:59:33
问题 I am trying to bind a repository to property using Ninject but always get null reference of binding object. I will explain the problem using code below. public interface IServiceRepository { User GetUser(string email); IQueryable<Statistic> GetStatisticForCurrentMonth(string ip); void InsertStatistic(ConversionModel conversionModel); class ServiceRepository : IServiceRepository { //Implementation of the Interface } I am would like to bind the repository above to class below while the class is

bind to property always return null

♀尐吖头ヾ 提交于 2019-12-25 09:57:27
问题 I am trying to bind a repository to property using Ninject but always get null reference of binding object. I will explain the problem using code below. public interface IServiceRepository { User GetUser(string email); IQueryable<Statistic> GetStatisticForCurrentMonth(string ip); void InsertStatistic(ConversionModel conversionModel); class ServiceRepository : IServiceRepository { //Implementation of the Interface } I am would like to bind the repository above to class below while the class is

Binding mediator (shortbus) with/to ninject

人盡茶涼 提交于 2019-12-25 01:43:48
问题 I am trying to use the mediator pattern with shortbus(https://github.com/mhinze/ShortBus). Everything goes great except binding it to ninject. There is a structuremap example like so public BasicExample() { ObjectFactory.Initialize(i => { i.Scan(s => { s.AssemblyContainingType<IMediator>(); s.TheCallingAssembly(); s.WithDefaultConventions(); s.AddAllTypesOf((typeof(IRequestHandler<,>))); s.AddAllTypesOf(typeof(INotificationHandler<>)); }); i.For<IDependencyResolver>().Use(() =>

MVC Ninject: How to add NinJect bindings from an MVC Area project

送分小仙女□ 提交于 2019-12-24 14:06:19
问题 I've been using this blog example: http://blog.longle.net/2012/03/29/building-a-composite-mvc3-application-with-pluggable-areas/ I have the concepts working in my solution. However, I'm trying to figure out a good way only add bindings to the kernel if a user has permissions to access a module/area. I've read up some on the ServiceLocator but I was trying to stay away from it. One thing I'm trying just to get things to work is user Contructor injection in the default constructor for a module.

Dependency Injection fails with MVC5 and Ninject

时光毁灭记忆、已成空白 提交于 2019-12-24 09:52:44
问题 I'm trying to inject a couple of classes in a controller, but I'm failing. This is what I've done: Added Ninject.Web.WebApi.WebHost and WebActivatorEx NuGet packages Created the following class under App_Start : NinjectWebCommon.cs using Microsoft.Web.Infrastructure.DynamicModuleHelper; using Ninject; using Ninject.Web.Common; using Ninject.Web.Common.WebHost; using MyProject; using MyProject.Models; using MyProject.Classes; using System; using System.Web; [assembly: WebActivatorEx

Custom AuthorizeAttribute Ninject Property Injection doesn't work (injected property have sub dependant services which need to be injected)

陌路散爱 提交于 2019-12-23 18:05:38
问题 I think the specifics of my question are very much different than the other similar questions which I have red. I know that when I have custom AuthorizeAttribute I can't inject dependencies with the constructor. This is because the constructor will take the parameters - in my case the permission strings. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] public class UserAllCSPermissionBasedAuthFilter : AuthorizeAttribute { I am

How to bind using Ninject Conventions Extension?

≡放荡痞女 提交于 2019-12-22 12:24:08
问题 I like to bind bellow code with Ninject auto binding. Is it possible to use both mannual & auto binding within a single project? Let;s take bellow manual binding, I want to achieve with auto binding. Please tell me how to achieve this. kernel.Bind<TestContext>().ToSelf().InRequestScope(); kernel.Bind<IUnitOfWork<TestContext>>().To<UnitOfWork<TestContext>>(); Bellow all interface inherited from base Interface : IRepository< Model > 3 . kernel.Bind<IUserRepository>().To<UserRepository>(); 4 .

Ninject, injecting Membership.Provider in RegisterServices of ninject initialization

陌路散爱 提交于 2019-12-22 10:29:12
问题 Anybody know how to configure Membership.Provider in RegisterServices of ninject initialization code? In my code: /// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { // Put additional bindings here kernel.Bind<IDatabaseFactory>().To<DatabaseFactory>(); kernel.Bind<IUnitOfWork>().To<UnitOfWork>(); kernel.Bind<IUserRepository>().To<UserRepository>(); kernel.Bind

Ninject Dependency Injection with Asp.Net MVC3 or MVC4

五迷三道 提交于 2019-12-22 05:06:38
问题 I am using Ninject MVC3(version 3.0.0.0) for my ASP.Net MVC3 application installed using NuGet Package for Dependency Injection. Here is the Global.asax change: public class MvcApplication : NinjectHttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("favicon.ico"); routes.IgnoreRoute

Ninject UnitOfWork confusion

独自空忆成欢 提交于 2019-12-20 05:46:08
问题 I use Ninject all the time with my MVC 3 applications, but I'm trying to change the Pattern for my Data Objects to use UnitOfWork and I'm having trouble figuring out how to get Ninject to handle this properly. I know my implementation of classes work when they are constructed manually like this in my console application: IDatabaseFactory factory = new DatabaseFactory(); IUnitOfWork worker = new UnitOfWork(factory); IBlogCategoryDao dao = new BlogCategoryDao(factory); IBlogCategoryService