ninject-2

Ninject conditional binding based on property value

纵饮孤独 提交于 2019-12-01 17:39:23
问题 I am having trouble defining bindings using ninject. I am in a standard ASP.NET WebForms application. I have defined an http handler to Inject dependencies in pages and controls (Property injection). Here is what I am trying to do: I am creating a custom combobox usercontrol. Based on the value of an enum on that combobox, I want to be able to Inject a different object in a property (What I am trying to do is a bit more involved than that, but answer to this should be enough to get me going).

ASP.NET MVC 3 Ninject Custom Membership and Role Provider

余生长醉 提交于 2019-11-30 20:33:09
Hi i got some problems enabling custom Membership and Role Provider, i got following error: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. System.InvalidOperationException: Default Membership Provider could not be found. It's pointing to my mvc3.ninject kernel.Inject(Membership.Provider) My MVC3.Ninject in app_start: private static void RegisterServices(IKernel kernel) { kernel.Inject(Membership.Provider); kernel.Inject(Roles.Provider); kernel.Bind

How does Ninject create controller in ASP.NET MVC?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 12:14:56
This may be stupid question, but I am looking at Ninject sources and don't see NInject registering its own controller factory. I also don't see any IControllerFactory class in Ninject.Web.Mvc assembly. Am I missing something? How does Ninject create controller and inject parameters into constructor? Lets say we are looking for "/Task/Index". Ninject MVC applications use now DefaultControllerFactory , the same as non-Ninject applications. DefaultControllerFactory finds type for controller ( TaskController ). DefaultControllerFactory has internal class called DefaultControllerActivator .

Need a simple example of using nhibernate + unit of work + repository pattern + service layer + ninject

本小妞迷上赌 提交于 2019-11-30 10:40:01
问题 I am using nhibernate + fluent nhibernate asp.net mvc 3 ninject Currently I am using nhibernate, ninject with the repository pattern and service layers. So I have this ninject public class NhibernateSessionFactory { public ISessionFactory GetSessionFactory() { ISessionFactory fluentConfiguration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("ConnectionString"))) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Framework.Data

ASP.NET MVC 3 Ninject Custom Membership and Role Provider

落爺英雄遲暮 提交于 2019-11-30 04:51:08
问题 Hi i got some problems enabling custom Membership and Role Provider, i got following error: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. System.InvalidOperationException: Default Membership Provider could not be found. It's pointing to my mvc3.ninject kernel.Inject(Membership.Provider) My MVC3.Ninject in app_start: private static void RegisterServices

Need a simple example of using nhibernate + unit of work + repository pattern + service layer + ninject

送分小仙女□ 提交于 2019-11-29 22:24:24
I am using nhibernate + fluent nhibernate asp.net mvc 3 ninject Currently I am using nhibernate, ninject with the repository pattern and service layers. So I have this ninject public class NhibernateSessionFactory { public ISessionFactory GetSessionFactory() { ISessionFactory fluentConfiguration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("ConnectionString"))) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Framework.Data.Mapping.TableAMap>().Conventions.Add(ForeignKey.EndsWith("Id"))) .ExposeConfiguration(cfg => cfg

Getting started with Ninject

笑着哭i 提交于 2019-11-29 03:26:37
问题 I watched the first 2 beginner tutorials for Ninject on dimecasts.net. Now, I want to use Ninject 2.2 in ASP.NET MVC 3. I want a view with a mocked out Model. I get object reference not set to an instance of an object when calling my service; public class HomeController : Controller { private readonly IMilestoneService _service; public HomeController() { } HomeController(IMilestoneService service) { _service = service; } public ActionResult Index() { ViewBag.Message = "Change Request System";

HttpHandler Property Injection using Ninject returning null

允我心安 提交于 2019-11-28 02:01:41
问题 I have the following httphandler: public class NewHandler : IHttpHandler { [Inject] public IFile FileReader { get; set; } public NewHandler() { } public void ProcessRequest(System.Web.HttpContext context) { .... var something = SomeMethod(FileReader); .... } public bool IsReusable { get { return true; } } } This is my Ninject Module in the Global.asax. internal class ServiceModule : NinjectModule { public override void Load() { Bind<IFile>().To<FileWrapper>().InSingletonScope(); } } Every

Dependency Injection with Custom Membership Provider

≯℡__Kan透↙ 提交于 2019-11-27 21:31:20
I have an ASP.NET MVC web application that implements a custom membership provider. The custom membership provider takes a UserRepository to its constructor that provides an interface between the membership provider and NHibernate. The UserRepository is provided by the Ninject IoC container. Obviously, however, this doesn't work when the provider is instantiated by .NET: the parameterless constructor does not have a UserRepository and cannot create one (the UserRepository requires an NHibernate session be passed to its constructor), which then means that the provider cannot access its data

Binding singleton to multiple services in Ninject

跟風遠走 提交于 2019-11-27 14:27:54
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 having is that if I bind the same provider method to: Func<Service> serviceCreator = () => new Service(false); kernel.Bind<IService>().ToMethod(serviceCreator).InSingletonScope(); kernel.Bind<Service>().ToMethod(serviceCreator).InSingletonScope(); It seems to be creating