Reputation: 509
Is there a way to dispose objects after creating them using the implementationFactory? Like so:
services.AddTransient(x => {
var objectA = new ObjectA(); //objectA needs to be disposed after the use of objectB
return objectA.ObjectB;
});
Upvotes: 0
Views: 245
Reputation: 509
I think this is the only proper way right?
services.AddTransient(x => new ObjectA());
services.AddTransient(x => {
var objectA = x.GetService<ObjectA>();
return objectA.ObjectB;
});
Upvotes: 1