回答

2

是不是真的在LightInject一個Release方法。一次性服務通過PerScopeLifetime或PerRequestLifetime進行註冊。

這些服務在周圍範圍處置時處置。

container.Register<IFoo, DisposableFoo>(new PerScopeLifetime()) 

using(container.BeginScope()) 
{ 
    var foo = container.GetInstance<IFoo>() 
} -- foo is disposed here 

LightInject.WebApi爲Web Api提供了一個集成,它在Web請求結束時負責處理控制器。

相關問題