autofac / Examples

Example projects that consume and demonstrate Autofac IoC functionality and integration
MIT License
392 stars 355 forks source link

Generalize the plugin demo for using external plugins not configured at compile time. #19

Closed moh-hassan closed 4 years ago

moh-hassan commented 4 years ago

The demo ConfigurationExample define both internal and external dependencies using a configuration file autofac.json In other scenarios, the plugins are loaded in external folder like a tree and are not defined at compile time. plugin folder Example:

----plugins
     |plugin1
     |   |-- plugin1.dll
     |   |--plugin1_nuget_lib.dll  //nuget package used by plugin1
     |plugin2
         | --plugin2.dll
         |...

So, autofac load the plugins from the assemblies in the plugin folder and manage its dependencies. It's nice if we have a demo for such scenario

tillig commented 4 years ago

If there are other strategies you want to employ to locate plugins, that's not something Autofac supports. Autofac doesn't even do the assembly loading, if you notice - all that assembly resolving handler stuff is .NET Core.

While we have a simple example there to show one possible way to handle plugins, Autofac isn't a plugin framework and we're not really prepared to take on recommendations around things like assembly loading safety, how to handle per-plugin dependencies, differences in how .NET Framework and .NET Core handle assembly loading, and so on. That's, unfortunately, going to be an exercise left to the reader. Sorry.

moh-hassan commented 4 years ago

I suggested this scenario because I found autofac documentation explain plugin topic for asp.net mvc as part of application integration.

tillig commented 4 years ago

Yep, which, unfortunately is yet another way to handle plugins (for ASP.NET MVC "classic" rather than ASP.NET Core). Different frameworks, different app types, different loading mechanisms... we just can't be responsible for showing folks how to do it because there is a lot to consider from security to dependency management and isolation. The best we can offer is a couple quick examples, but any more is beyond what we are able to support for our users. Again, we're a DI library, not a plugin framework, though I recognize there is a desire to overlap the two concepts.