Let's assume i have the following ASP.NET webapi controller:
[RoutePrefix("api/Foo")]
public sealed class FooController : ApiController
{
private static readonly NativeFooService _nativeFooService = new NativeFooService();
// Controller actions
}
NativeFooService
implements IDisposable
and contains some heavy initialization code in constructor, so I really-really do not want to make it non-static member of my controller, but at the same time I want to call make sure it is disposed correctly, cause it is wrapping some native components.
The question is, should I care about calling Dispose
on NativeFooService
by using something like IRegisteredObject, or should I just leave all trouble to ASP.Net runtime?