I'm trying to achieve something but can't get my head around how to do it. Basically I have multiple interfaces implementations marked with a custom Export attribute, so they get picked up by MEF, and the catalog in which they are is registered in a UnityContainer.
The constructor of these implementations have the ImportingConstructor so unity can inject the parameters when MEF creates a requested part. This bit works just fine.
My problem is, I need to setup interception on certain types in the catalog, and I'm using Unity interception and this cannot be changed in my scenario. Here how it was configured before using MEF to load them:
unityContainer.RegisterType<IAuthenticationService, AuthenticationService>().Configure<Interception>().SetInterceptorFor<IAuthenticationService>(new InterfaceInterceptor());
My new code to load these using MEF:
DirectoryCatalog directoryCatalog = new DirectoryCatalog(".");
FilteredCatalog servicesCatalog = new FilteredCatalog( /* filtering on a metadata of the custom export attribute */ );
// servicesCatalog is properly populated at this point
// TODO: need to setup interception, as in the previous code block, on the servicesCatalog parts, without knowing the interface and implementation names (IAuthenticationService, AuthenticationService) except by looking at the ExportDefinitions. So I'm Stuck Here!
// resolving a known interface here, loaded from MEF catalog above, works perfectly fine, Unity injects construct parameters to that instance being constructed by MEF, so my 2-way integration is fine.
But now that all I have is a FilteredCatalog with ComposableParts, I simply don't know how to adapt my interception code using MefContrib.Interception.Unity, and I can't seem to find any documentation or samples on this matter.
Any help would greatly be appeciated.