mirror of https://github.com/abpframework/abp.git
1 changed files with 54 additions and 1 deletions
@ -1,3 +1,56 @@ |
|||||
# Plug-In Modules |
# Plug-In Modules |
||||
|
|
||||
TODO |
It is possible to load [modules](Module-Development-Basics.md) as plug-ins. That means you may not reference to a module's assembly in your solution, but you can load that module in the application startup just like any other module. |
||||
|
|
||||
|
## Basic Usage |
||||
|
|
||||
|
`IServiceCollection.AddApplication<T>()` extension method can get options to configure the plug-in sources. |
||||
|
|
||||
|
**Example: Load plugins from a folder** |
||||
|
|
||||
|
````csharp |
||||
|
using Microsoft.AspNetCore.Builder; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity.PlugIns; |
||||
|
|
||||
|
namespace MyPlugInDemo.Web |
||||
|
{ |
||||
|
public class Startup |
||||
|
{ |
||||
|
public void ConfigureServices(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddApplication<MyPlugInDemoWebModule>(options => |
||||
|
{ |
||||
|
options.PlugInSources.AddFolder(@"D:\Temp\MyPlugIns"); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public void Configure(IApplicationBuilder app) |
||||
|
{ |
||||
|
app.InitializeApplication(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
```` |
||||
|
|
||||
|
* This is the `Startup` class of a typical ASP.NET Core application. |
||||
|
* `PlugInSources.AddFolder` gets a folder path and to load assemblies (typically `dll`s) in that folder. |
||||
|
|
||||
|
That's all. ABP will discover the modules in the given folder, configure and initialize them just like regular modules. |
||||
|
|
||||
|
### Plug-In Sources |
||||
|
|
||||
|
`options.PlugInSources` is actually a list of `IPlugInSource` implementations and `AddFolder` is just a shortcut for the following expression: |
||||
|
|
||||
|
````csharp |
||||
|
options.PlugInSources.Add(new FolderPlugInSource(@"D:\Temp\MyPlugIns")); |
||||
|
```` |
||||
|
|
||||
|
> `AddFolder()` only looks for the assembly file in the given folder, but not looks for the sub-folders. You can pass `SearchOption.AllDirectories` as a second parameter to explore plug-ins also from the sub-folders, recursively. |
||||
|
|
||||
|
There are two more built-in Plug-In Source implementations: |
||||
|
|
||||
|
* `PlugInSources.AddFiles()` gets a list of assembly (typically `dll`) files. This is a shortcut of using `FilePlugInSource` class. |
||||
|
* `PlugInSources.AddTypes()` gets a list of module class types. If you use this, you need to load the assemblies of the modules yourself, but it provides flexibility when needed. This is a shortcut of using `TypePlugInSource` class. |
||||
|
|
||||
|
If you need, you can implement your own `IPlugInSource` implementation and add to the `options.PlugInSources` just like the others. |
||||
Loading…
Reference in new issue