Asp.net mvc 如何在Ninject中使用griffin.mvccontrib.localization

Asp.net mvc 如何在Ninject中使用griffin.mvccontrib.localization,asp.net-mvc,localization,ninject,autofac,griffin.mvccontrib,Asp.net Mvc,Localization,Ninject,Autofac,Griffin.mvccontrib,我正在尝试在我的Asp.net MVC应用程序中使用MVC Contrib本地化,现在我可以用它处理资源文件,但我想用它处理Sql Server 我正在查看此教程: 但它使用Autofac作为IoC容器,我不明白,有人用过Ninject吗?或者任何人都知道如何将此Autofac代码传输到Ninject: // Loads strings from repositories. builder.RegisterType<RepositoryStringProvider>().AsImpl

我正在尝试在我的Asp.net MVC应用程序中使用MVC Contrib本地化,现在我可以用它处理资源文件,但我想用它处理Sql Server

我正在查看此教程:

但它使用Autofac作为IoC容器,我不明白,有人用过Ninject吗?或者任何人都知道如何将此Autofac代码传输到Ninject:

// Loads strings from repositories.
builder.RegisterType<RepositoryStringProvider>().AsImplementedInterfaces().InstancePerLifetimeScope();
builder.RegisterType<ViewLocalizer>().AsImplementedInterfaces().InstancePerLifetimeScope();

// Connection factory used by the SQL providers.
builder.RegisterInstance(new AdoNetConnectionFactory("DemoDb")).AsSelf();
builder.RegisterType<LocalizationDbContext>().AsImplementedInterfaces().InstancePerLifetimeScope();

// and the repositories
builder.RegisterType<SqlLocalizedTypesRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
builder.RegisterType<SqlLocalizedViewsRepository>().AsImplementedInterfaces().InstancePerLifetimeScope();
//从存储库加载字符串。
builder.RegisterType();
builder.RegisterType();
//SQL提供程序使用的连接工厂。
builder.RegisterInstance(新的AdoNetConnectionFactory(“解调器”)).AsSelf();
builder.RegisterType();
//以及存储库
builder.RegisterType();
builder.RegisterType();

提前感谢。

我正在尝试用Ninject.Web.MVC NuGet包做同样的事情

我不确定Ninject是否有类似于
.AsImplementedInterfaces()
的功能,但是如果没有,您仍然可以自己绑定接口,这只是查看Griffin.MvcContrib的类及其实现的接口的更多手动工作

NinjectWebCommon RegisterServices方法中的一个示例是:

private static void RegisterServices(IKernel kernel)
{
    kernel.Bind<ILocalizedStringProvider>()
           .To<RepositoryStringProvider>().InRequestScope();
...
}  
私有静态无效注册服务(IKernel内核)
{
kernel.Bind()
.To().InRequestScope();
...
}  
从我到目前为止所读到的内容来看,RequestScope中的
InRequestScope
extension(),是我所能看到的最接近AutoFac
。InstancePerLifetimeScope()

至于
.RegisterInstance(新的AdoNetConnectionFactory(“DemoB”)).AsSelf()

Ninject有一个
.ToSelf()
方法,但我自己还不能完全确定这行代码在做什么