简体   繁体   中英

Plugins for ASP.Net Webapplication

i'm working on a webapplication written in C# using the ASP.NET MVC framework.

I want to allow my clients to write their own plugins for the web application. Each client get it's own database.

I got some ideas how to do this:

  1. I will provide an interface which allows the user to upload his assembly dll. This will store the dll in a specific plugins-folder for the client.
  2. I will provide some C# Interfaces and Attributes for Class and Method annotations.
  3. The business logic of the server will check each plugin and search for classes and methods with these attributes or interface implementations to override or alter it's default behavior on certain points.
  4. For performance, I'll implement some form of caching that gets invalidated every time a new plugin is uploaded.

Now my question:

How can i allow the user to write a plugin? I mean how to provide some kind of SDK for this? The user primary needs the C# interfaces and Annotations but the developer also want's to test the plugin before uploading it to the production server. Can i pack my webapplication in some kind of DLL which could be loaded by the developer for testing purposes but not read the source code? Or is there any other way of doing this?

Thank you for any info on this!

You should take a look at MEF (Managed Extensibility Framework) this is a framework Microsoft created to enable applications for plugins.

In short: You create a library with contracts (interfaces). You give that library to your customers and tell them to write plugins based on those interfaces.

Then you tell your application that when it needs IPlugin it needs to search the plugin folder for an implementation of IPlugin and use that.

Some research urls:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM