如何增加新对象Application_Started后跟踪Ninject? [英] How to add new object to track in Ninject after Application_Started?
问题描述
是否有可能增加一个新的对象,被激发Ninject应负责在 Application_Started
事件发生后的ASP.NET应用程序(终身,注射等)?
Is it possible to add a new object that Ninject should be responsible for (lifetime, injection etc.) in an ASP.NET application after the Application_Started
event is fired?
我的应用程序需要动态指定在应用程序启动后,应该很好跟踪对象
My application needs to dynamically designate objects that should be tracked well after the application is started
推荐答案
如果你有机会到的Application_Start $创建
内核
对象C $ C>或者通过使用的公共服务定位器,你应该能够调用绑定< T>()
来更新上下文的对象。
If you have access to the Kernel
object created at Application_Start
either by a static reference or [preferably] by use of a Common Service Locator, you should be able to call Bind<T>()
on the object to update the context.
我没有亲自试过,但它确实符合阶级结构。
I haven't personally tried this, but it does comply with the class structure.
这篇关于如何增加新对象Application_Started后跟踪Ninject?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!