ninject

Ninject and Custom Controller Factory

此生再无相见时 提交于 2019-12-13 04:27:51
问题 I'm using MEF with ASP.NET MVC as demonstrated at http://blog.maartenballiauw.be/post/2009/06/17/Revised-ASPNET-MVC-and-the-Managed-Extensibility-Framework-(MEF).aspx. When I try to use Ninject, it seems that nothing gets injected. I did some debugging, and when I reverted to the original controller factory the injection worked. What needs to be changed, or what does Ninject need in terms of controller factories for it to work? 回答1: Check out Nate Kohari's Ninject.Web.MVC project on GitHub.

Understanding Ninject with a more complex scenario

扶醉桌前 提交于 2019-12-13 02:43:56
问题 I am trying to use ninject to.. well do what ninject does.. Basically the injection isnt happening. In my code below I am creating the Kernel in my "test" and expecting an IDrinkCan implementation to somehow get into my CokeComsumer class. I think i have missed something here.. since the IDrinkCan is null when I put a break point on the CokeConsumer constructor. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ninject; using Ninject.Modules; using

Ninject contextual binding for 2+ dependent classes w/ different names for same constructor param

删除回忆录丶 提交于 2019-12-13 02:26:28
问题 Having trouble figuring out how to manage contextual binding in the scenario where two classes have the same underlying interface dependency, but each class ctor's parameter is named differently. Pseudo code below to demonstrate my situation: interface IThing { } public class Thing1 : IThing { public Thing1(string fileCode) { } } public class Thing2 : IThing { public Thing2(string fileCode) { } } interface IThingFactory { IThing CreateThing(string fileCode); } interface IDependentThing { }

Ninject: No matching bindings are available, and the type is not self-bindable

那年仲夏 提交于 2019-12-13 02:09:06
问题 Edit: Problem solved This is my error message: Message=Error activating IValueCalculator No matching bindings are available, and the type is not self-bindable. Activation path: 1) Request for IValueCalculator Suggestions: 1) Ensure that you have defined a binding for IValueCalculator. 2) If the binding was defined in a module, ensure that the module has been loaded into the kernel. 3) Ensure you have not accidentally created more than one kernel. 4) If you are using constructor arguments,

Ninject - How to implement Command Pattern with Ninject?

假装没事ソ 提交于 2019-12-13 00:46:29
问题 Currently, I'm implementing the command pattern with ninject doing the following bindings: kernel.Bind<ICommand<InsertParams>>().To<InsertProductCommand>(); kernel.Bind<ICommand<UpdateParams>>().To<UpdateProductCommand>(); kernel.Bind<ICommand<DeleteParams>>().To<DeleteProductCommand>(); My question is: these definitions and commands can grow over the time. Is there any way to reduce all these bindings to something like 'Bind(typeof(ICommand<>))' so that every interface depending on the

MVC3 tool using Entity Framework caching issues with Ninject

放肆的年华 提交于 2019-12-13 00:22:52
问题 I've got a new MVC 3 application which is showing some issues when modifying data manually in the Database. The tool is still in development and once in a while I want to change my user's teamId. When I do so, I have to kill the Web development Server and run it again otherwise the queries don't pick the new teamId. Same thing when I publish the tool to IIS, if I ever modify something on the database, I need to either copy over the 'bin' folder again or stop the application and re-run it.

Configure Ninject for 3 layers architecture in MVC 4

不想你离开。 提交于 2019-12-12 21:02:42
问题 Currently, I'm building a website with 2 layers. Web UI: this is a MVC 4 project, used to interact with users Data Access: this is a C# library. This layer is responsible for interacting with database. I'm using Ninject for Dependency Injection. Up to now, it's OK. But now, I want to insert a new layer between Web UI and Data Access , called Business Logic. So the architecture would be: Web UI: uses interface from business logic. Business logic: uses interface from data access. Data access:

how to get better (any?) diagnostics out of ninject why its throwing ActivationException?

做~自己de王妃 提交于 2019-12-12 19:10:01
问题 Ok, so I am using both Automapper (LOVE it!) and ninject (very fond of it, but we have "issues" :-). I am writing MVC3 apps. When I mess something up in Automapper configuration, Automapper goes to great lengths to tell me exactly what I did wrong, providing all necessary details. When I mess something up in ninject configuration, it says "something is wrong". Well, not even quite that. If I am lucky enough to have the output window open, I hopefully see a message fly by akin to "first chance

UnitOfWork with NInject design issues

社会主义新天地 提交于 2019-12-12 17:17:17
问题 I have my UnitOfWork class in DataAccess project and to resolve my IUnitOfWork interface (with UnitOfWork class), I need to use Ninject to Bind the IUnitOfWork interface with UnitOfWork class in my web project. To do this I need to refer my DataAccess project (which contains UnitOfWork class) in the Web project. Is this good design wise? I mean referring DataAccess in the web project seems to be a bad idea & I never did that. So, please advise me on what to do? 回答1: If you are not comfortable

AutoMapper with Ninject confusion

百般思念 提交于 2019-12-12 15:19:21
问题 For starters I'm using this module: public class AutoMapperModule : NinjectModule { public override void Load() { Bind<ITypeMapFactory>().To<TypeMapFactory>(); foreach (var mapper in MapperRegistry.AllMappers()) { Bind<IObjectMapper>().ToConstant(mapper); } Bind<AutoMapper.ConfigurationStore>().ToSelf().InSingletonScope().WithConstructorArgument("mappers", ctx => ctx.Kernel.GetAll<IObjectMapper>()); Bind<IConfiguration>().ToMethod(ctx => ctx.Kernel.Get<AutoMapper.ConfigurationStore>()); Bind