BoDi icon indicating copy to clipboard operation
BoDi copied to clipboard

Support disposal of objects returned by RegisterFactoryAs

Open jonathansapp opened this issue 7 years ago • 1 comments

@gasparnagy

BoDi does not currently provide any way to track and automatically dispose of objects returned from factory delegates. The following code changes enable this functionality while preserving the existing behavior.

The purpose of this PR is to make the changes necessary so that AutoFac lifetime scopes can be properly disposed between scenarios. See open SpecFlow issue Lifetime is Incorrect #12.

Usage:

void RegisterFactoryAs<TInterface>(Func<IObjectContainer, TInterface> factoryDelegate, string name = null, bool dispose = false)

jonathansapp avatar May 29 '18 18:05 jonathansapp

@jonathansapp Thx! Could you please also add a line about this change to the bodi.cs header (change history)?

gasparnagy avatar Aug 13 '18 07:08 gasparnagy