natemcmaster / DotNetCorePlugins

.NET Core library for dynamically loading code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question]

Teknel opened this issue · comments

Is it possible to obtain a list of plugins without loading the assemblies, in the style of what can be done with MEF and the metadata associated to the class of the plugin?
Thanks

Can you be more precise about what you mean by "list of plugins"? Are you looking for a specific type or classes that implement an interface or something else?

We have an application that implements devices through plugins.
Each device has an ID, which corresponds to a property defined in the plugin that controls it.

The requirement is to instantiate only the class that contains the required plugin with the assembly that contains it, so not to load all available assemblies, since only a few of a large amount available are used.

Before .Net Core 3.1 we made them through attributes, catalogs and Lazy load in MEF, that way we could load a list with the properties exported through the metadata of each plugin without having to instantiate them and only do it with the plugin with the matched ID.

In short, how can we have a list of available plugins with properties that identify their functionality without the need to instantiate them.

Thank you

Thanks for the additional info. This library will only load assemblies when they are requested (usually done via PluginLoader.LoadAssembly). You would need to write your own code to handle the ID/class instantiation pattern you described, but it should be possible to implement what you described using this library to assist with assembly loading.

Thanks for the quick response.
That is, this library can only be used for loading the specified assembly (which is not small).
Any idea of the type of technology to use to achieve the extraction of the ID / class?

Thank you.

Yes, the primary purpose of this library is to make assembly loading easier to work with. Think of this like a better version of "Assembly.LoadFile".

Two ideas comes to mind:

  • use System.Relfection
  • Store this information in an XML or JSON file

I'm sure there are other ways to do it.

I will share our final solution.

Thanks again.