How to use plugin architecture in ASP.NET?

I really like the plugin architecture in WinForms. I want to use the plugin architecture in Asp.net.BUT. I was looking for plugins. In asp.net, I created asp.net MVC samples. Walnut I do not want to use the microsoft mvc repository. I want to use the classic asp.net project. But I do not find a sufficient result ....

+4
source share
2 answers

You can roll on your own.

The plugin architecture requires several not very complex parts:

  • A way to determine where the plugin DLL is located.
  • The definition of the interface or base class that all plugins must adhere to. It's the most important. It decides what functionality your plugin can offer, and how deeply it can integrate with your application.
  • The place (in time) when your plugin is loaded and executed. (i.e. does the plugin execute for each request of a web page or for requests matching a specific name? Or does the page manually call plugins?)

Once you figure this out, instantiating the plugin is simple. It works the same regardless of whether you work in a web application or on a client:

System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(plugin_path); t = a.GetType("IPlugin"); IPlugin plugin = (IPlugin)Activator.CreateInstance(t); 

then you can use plugin.DoSomething() to actually call functions from the plugin. (Do I need to display part of the html or save it in the database or something else)

+14
source

Source: https://habr.com/ru/post/1342951/


All Articles