我应该在分配后处置注入的变量

时间:2018-11-22 15:19:35

标签: c# asp.net-mvc ninject ioc-container dispose

我正在为ASP.NET MVC Web应用程序使用活动目录服务类。我将Ninject用于IOC。我通过以下方式将Forest注入班级。

private readonly Forest forest;
public ActiveDirectoryServices(Forest forest)
{
   this.forest = forest;
}

在我的NinjectWebCommon中,使用以下绑定。

kernel.Bind<Forest>().ToSelf().InRequestScope();

然后,在我的函数中,将一个新的Forest分配给我注入的forest变量。

this.forest = Forest.GetCurrentForest();

我知道,如果我使用InRequestScope()绑定,则将ninject处理对象处置,但是在进行新的引用分配后是否也是如此? 我的问题是,我应该在班级中放置林场,还是Ninject会处理它?<​​/ p>

0 个答案:

没有答案
相关问题