获取SNAP(AOP),NInject和ASP.Net MVC 3合作 [英] Getting SNAP(AOP), NInject and ASP.Net MVC 3 working together

查看:163
本文介绍了获取SNAP(AOP),NInject和ASP.Net MVC 3合作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人得到了SNAP AOP框架与MVC 3和Ninject工作。

Has anyone got the SNAP AOP framework working with MVC 3 and Ninject.

使用的NuGet到MVC 3项目没有比较特别了$ P $以及增加工作时捕捉给出的样本pviously添加NInject包。我试图得到它的工作基于正常NInject办法,但只是不能让它真正拦截!

The samples given when adding Snap using NuGet to an MVC 3 project don't specifcally work well with a previously added NInject package. I have tried to get it working based on the normal NInject approach but just cannot get it to actually intercept!

任何人都可以显示如何在code做到这一点吗?

Can anyone show how to do this in code please?

推荐答案

我通过的NuGet最新版本Ninject的现在增加了一个一流的呼叫NinjectMVC3在新AppStart的文件夹中的MVC3应用了它。

I figured it out with the latest version of Ninject through NuGet which now adds a class call NinjectMVC3 in a new AppStart folder in the MVC3 application.

在code我用的是folows:
在自动创建NinjectMVC3.cs CreateKernel()方法: -

The code I used is as folows: In the automatically created NinjectMVC3.cs CreateKernel() method:-

         private static IKernel CreateKernel()
        {
            // Wire it up with AOP
            NinjectAopConfiguration.NinjectAopConfigure();

            //var kernel = new StandardKernel(); // Removed

            RegisterServices(NinjectAopConfiguration._container.Kernel);

            return NinjectAopConfiguration._container.Kernel;
        }

我也接线Ninject在RegisterServices各注入目标()方法。

I also wired up Ninject for the various injection targets in RegisterServices() method.

接下来,我花了通过的NuGet时产生加SNAP.Ninject到MVC 3应用程序,更名NinjectAOP.cs样品code和使它看起来是这样的:

Next I took the sample code generated by NuGet when adding SNAP.Ninject to the MVC 3 application, renamed it NinjectAOP.cs and made it look like this:

 public static class NinjectAopConfiguration
    {
        public readonly static NinjectAspectContainer _container;

我也需要做一个程序集绑定重定向Ninject如下因为有一个程序集版本冲突某处Ninject:

I also needed to do an assembly binding redirect for Ninject as follows because there is an assembly version conflict somewhere for Ninject:

我希望这可以帮助别人。

I hope this helps someone.

我邀请任何人去看看,看看他们是否能改善这个吧。

I invite anyone to have a look and see if they can improve this please.

这篇关于获取SNAP(AOP),NInject和ASP.Net MVC 3合作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆