Non-generic ExportProvider.GetExports(Type) method missing
See original GitHub issueGiven 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); // ??
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
c# - The non-generic method 'IServiceProvider.GetService ...
It means your compiler only has knowledge of the method that takes a type. You could call var incoming = serviceProvider.GetService(typeof( ...
Read more >ExportProvider.GetExports Method
Gets all exports that match the conditions of the specified import definition and composition. GetExports(Type, Type, String). Gets all the exports with the ......
Read more >ComposeExportedValue<T> in MEF2 (System.Composition)
Shows how to generate exports on the fly so that they can be injected into constructors of the types that depend on them...
Read more >https://raw.githubusercontent.com/dotnet/samples/m...
24611 area-Serialization Ignore the type in SGEN if it contains any ... TryGetValue not found out value for other classes: Function | actual...
Read more >Managed Extensibility Framework - RSSing.com
Bascially I've got a session factory class which imports the fluent configuration and exports new NHibernate ISessions through a function with the attribute ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?):I managed to create an extension method for the following method:
Getting it done for the very much needed
GetExported()
method is way harder due to the complex conversion needed for the return value. 😢Source code