ninject

Ninject dynamic multiple constructor arguments

耗尽温柔 提交于 2019-12-23 02:56:09
问题 I have been implementing Dependency Injection into an existing Winforms project and it has been going well so far, however I want to generalise the calling of the Forms, specifically the varying quantity of constructor parameters. My code is as follows: Public Shared Function GetForm(formObject As BaseObject, _ parameters As Dictionary(Of String, Object)) As Form Select Case formObject.GetType() Case GetType(Production.Task) Return SMKernel.Kernel.Get(Of Forms.Production.Domain.ManageTask) _

Tutorial About IoC + NHibernate + MVC

余生颓废 提交于 2019-12-23 02:53:12
问题 I was following up Jason Dentler's series of posts on how to use NHibernate + Ioc (Ninject) with a real world ASP.NET MVC N-Tier application. Sadly he dropped the series. Does anyone has any good suggestions of articles that cover a similar scenario? I would be very interesting in learning such things. 回答1: Bob Cravens TruckTracker turorials utalise MVC, NHibernate, Ninject and MySQL. I have found them to be an invaluable resource. 回答2: I don't know about tutorials but I think that you should

Configuring Ninject to return a list of results

余生颓废 提交于 2019-12-23 02:01:38
问题 I'm using Ninject to resolve dependencies and it's working swimmingly until now. In this example, I actually need a list of objects initialized based on data stored in my App.config. However, Ninject keeps returning an empty list. The snippet below is an example of what I tried. I've included the constructors for the class hierarchy for some context. public ServiceSchedulerBuilder(IList<ITextExportService> textExportServices) { _textExportService = textExportServices; } public

Configuring Ninject to return a list of results

眉间皱痕 提交于 2019-12-23 02:01:28
问题 I'm using Ninject to resolve dependencies and it's working swimmingly until now. In this example, I actually need a list of objects initialized based on data stored in my App.config. However, Ninject keeps returning an empty list. The snippet below is an example of what I tried. I've included the constructors for the class hierarchy for some context. public ServiceSchedulerBuilder(IList<ITextExportService> textExportServices) { _textExportService = textExportServices; } public

How to rollback nHibernate transaction when an exception occurs during request having Ninject for managing sessions?

浪子不回头ぞ 提交于 2019-12-22 14:53:51
问题 I use nHibernate for ORM and Ninject for IoC. I create nHibernate sessions per some custom scope (which you can assume is per request). I begin the transaction onActivation. I commit the transaction onDeactivation. The problem is that if an exception happens during the request I want to rollback the transaction rather than committing it. Any idea how to detect (in a clean way, most probably using Ninject Context) that an exception has happened? Note: I am not concerned about the exceptions

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 interception proxying class with non empty constructor via castle dynamic proxy

人走茶凉 提交于 2019-12-22 11:00:12
问题 I am basing most of my current implementation off the information provided here: Ninject Intercept any method with certain attribute? I use a custom planning strategy class which looks for all methods with given attributes (not ninject interceptor attributes) which will then get proxied if it matches the criteria. An example of usage would be: Kernel.Components.Add<IPlanningStrategy, CustomPlanningStrategy<LoggingAttribute, LoggerInterceptor>>(); This would then look for any methods which

Ninject problem binding to constant value in MVC3 with a RavenDB session

柔情痞子 提交于 2019-12-22 10:56:11
问题 I've seen a lot of different ways of configuring Ninject with ASP.NET MVC, but the implementation seems to change slightly with each release of the MVC framework. I'm trying to inject a RavenDB session into my repository. Here is what I have that's almost working. public class MvcApplication : NinjectHttpApplication { ... protected override void OnApplicationStarted() { base.OnApplicationStarted(); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters);

Building a WinForms Application using MVC and Ninject as IoC Container

久未见 提交于 2019-12-22 09:59:26
问题 I am having to re-write a large WinForms application and I want to use MVC to allow increased testing capability etc. I want to also adopt Ninject as my IoC container as it is lightweight, fast and will increase the exstensibility of my application going forward. I have done a great deal of reading and I have managed to make a start on the arcitecture of this new application. However, I am not sure i have the right idea when using Ninject. The code... Starting with Program.cs and related

How to decorate interfaces bound to more than one concrete type with Ninject

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 08:35:01
问题 So, I have a message bus that instantiates message handlers through Ninject. I'd like to decorate my handlers with cross cutting concerns such as logging, transaction management, etc. I setup my bindings like so: kernel.Bind<IMessageHandler<int>>().To<IntHandlerOne>() .WhenInjectedInto(typeof(HandlerDecorator<>)); kernel.Bind(typeof(IMessageHandler<>)).To(typeof(HandlerDecorator<>)); Which works fantastically whenever I have a single handler of a specific message type. However, when I have