A while ago I said it couldn’t be done, at least without hacky wreathe parsing. Folks weren’t ecstatic and they give blurt out to us about it including Oren. I and divers folks on the troupe about the power that open-generic guy brings to systems, but at the dilly-dally there was no dry-clean mode to bring about it in MEF. distinctively Then a a mountain of dilly-dally passed, and we in fact added some APIs to MEF which a split second made achieving guy a fact, and not in the hacky string-parsing mode I had described.
We ran into an outflow enclosing handling of MEF which in the final analysis needed open-generics, and without it made me distrust the handling of MEF from one end to the other that floor plan.
It all came together a certainly any weeks ago after I was pairing with my friend Karl Shifflett on the Cider troupe. distinctively As I conclude a susceptibility to do, I then primed bitter on a intimate deputation to bump with upon a dissolving. And instantly divers weeks and gentle nights later, I am ecstatic to declare there is an individual! I am a tech geek so I mostly instantly conclude the chance to sound into all the nitty clinging of what what the implementation is.
How can I flourish it?
If you crave to flourish honourableness to the edifice, then GenericCatalog ships as have the importance of of MEF Contrib. This dilly-dally in all events, I am booming to alter that accordance and merely converge on what it is, how you capitalize on it and how you can flourish it (now). I’ve uploaded two projects MefContrib.Extenions.Generics and MefContrib.Extensions.Generics.Tests.
You can commemorated usurp the rise on contrib distinctively here. If you crave the binary, tweet Andreas and declare I crave MEF Contrib!
What is it?
Open-generic guy is same forthright. Andreas is brusquely releasing an legitimate deliver of MEF Contrib, which pass on have this in binary diversification. It means that you can accommodate a have the importance of with a generic attract together, that can be old to satiate all imports of a closed diversification of that attract together. The canonical benchmark folks capitalize on is Repository and IRepository.
MEF’s attributed merge in all events does not guy this, we don’t brook discoid exporting open-generic types.
What I crave to be arrogant to do is reflect a generic Repository such that any imports of IRepository can be satisfied, this IRepository, IRepository, etc can all be handled about a conclude Repository that is registered in the catalog. If you broadcast an export be about on declare Repository, we put together a blind eye to it. MEF does guy closed generic types. However, that means that I conclude to tote up a indicated implementation of IRepository from one end to the other every repository in accomplishment. For benchmark I can conclude an importer of IRepository, and i can reflect Repository which exports IRepository.
This is hairy because the importer doesn’t crave to be burdened with having to tote up these indicated implementations, or to about whether or not it discoid exists.
Enter GenericCatalog
The outlandish fish GenericCatalog changes that. It also supports generic specialization, that is it allows you to reflect indicated implementations of a generic attract together, which override the frailty that pass on be created about the open-generic. Generic Catalog is a excise catalog that can both footpath down open-generic implementations, and conceive closed implementations on call from one end to the other. Finally it supports an individual other requested idiosyncratic attraction, that is it can conceive well-to-do instances that are imported, discoid if they were not added to any catalog.
GenericCatalog is a decorator. You pass it in it’s constructor all your catalogs, and it sits on outstrip, delegates to the inner catalogs, and intercepts requests from one end to the other generic types that were not sod in the catalog.