Reputation: 6611
Is it possible to intercept dependency requests in MEF before they get handled by MEF?
This would be useful for implementing decorators and advanced lifetime management.
Something like...
catalogue.AddInterceptor<IExpensiveService>(b => ... return from pool ...);
Or even...
catalogue.AddInterceptor<IExpensiveService>(b => new Decorator(b()));
(where 'b' is the underlying MEF resolution func for resolving the service)
Upvotes: 0
Views: 1233
Reputation: 66733
Not out of the box, but you can write your own ExportProvider or ComposablePartCatalog implementation to do this.
MefContrib appears to have implemented something like that, take a look at InterceptingCatalog. See also this (possibly outdated) blog post about it.
Upvotes: 1