Question

Assuming that I have the following interface and class:

public interface IFooRepo : IDisposable { 

    //...
}

public FooRepo : IFooRepo { 

    //Methods here

    //Properly implement the IDisposbale.Dispose() here
}

I use Autofac as IoC container in my application and if I register this as below, can I be sure that it will disposed properly?

private static IContainer RegisterServices(ContainerBuilder builder) { 

    builder.RegisterType<FooService>().As<IFooService>();

    return
        builder.Build();
}

Or should I take further steps depending on the application type I am using. (In this case, I using ASP.NET MVC but I am considering using autofac in a WCF Web API project and a class library)

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top