vs-mef: Non-generic ExportProvider.GetExports(Type) method missing
Given a Type
variable, how can I get its export?
public object Resolve<T>() => exportProvider.GetExportedValue<T>(); // OK
public object Resolve(Type type) => exportProvider.GetExportedValue(type); // ??
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- Add non-generic GetExports/GetExportedValues methods to ExportProvider Closes #137 — committed to AArnott/vs-mef by AArnott 5 years ago
- Fix GitHub workflow file syntax error (#137) — committed to microsoft/vs-mef by AArnott 2 years ago
I cannot speak for the OP, but I had the same requirement a few years ago when I had to implement
IServiceProvider
through a composition container. I don’t remember how I solved it back then, but I did get it to work via vs-mef at some point. These days I don’t see much usage of IServiceProvider so unfortunately I don’t have this trick in my codebase anymore.I think if you expose GetContractName publically that should be enough, I think you can just pass
object
into the generic parameter of e.g.GetExportedValue
together with the contract name, something like that already seems to work (unless there is a hidden edge case where it fails?):