I am working on a library which needs to make use of the common service locator (http://commonservicelocator.codeplex.com/) to provide generic IOC support in order that we don’t conflict with any consumers. Obviously I don’t want to reference the IOC frameworks directly in my project but I’m unsure as to how to annotate the parts such that they can be found by the various frameworks. For instance MEF usually works by finding classes with the Export annotation and LinFu by finding classes with the Implements annotation. Both these annotations are defined within their respective projects requiring that I reference them both.
How can I get away from adding all these classes and annotating all my classes multiple times? It certainly doesn’t adapt well to new IOC frameworks as a rebuild would be required for each new framework’s annotations.
From the documentation:
So I don’t think you need to export anything, just document what you need to consume in order to run. And optionally use the ServiceLocator.Current interface to resolve any dependencies you require.