diff --git a/docs/en/PlugIn-Modules.md b/docs/en/PlugIn-Modules.md index 5df505ade0..5522aec05e 100644 --- a/docs/en/PlugIn-Modules.md +++ b/docs/en/PlugIn-Modules.md @@ -53,4 +53,71 @@ 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 create your own `IPlugInSource` implementation and add to the `options.PlugInSources` just like the others. \ No newline at end of file +If you need, you can create your own `IPlugInSource` implementation and add to the `options.PlugInSources` just like the others. + +## Creating a Simple Plug-In + +Create a simple **Class Library Project** in a solution: + +![simple-plugin-library](images/simple-plugin-library.png) + +You can add ABP Framework packages you need to use in the module. At least, you should add the `Volo.Abp.Core` package to the project: + +```` +Install-Package Volo.Abp.Core +```` + +Every [module](Module-Development-Basics.md) must declare a class derived from the `AbpModule`. Here, a simple module class that resolves a service and initializes it on the application startup: + +````csharp +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Modularity; + +namespace MyPlugIn +{ + public class MyPlungInModule : AbpModule + { + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var myService = context.ServiceProvider + .GetRequiredService(); + + myService.Initialize(); + } + } +} +```` + +`MyService` can be any class registered to [Dependency Injection](Dependency-Injection.md) system, as show below: + +````csharp +using Microsoft.Extensions.Logging; +using Volo.Abp.DependencyInjection; + +namespace MyPlugIn +{ + public class MyService : ITransientDependency + { + private readonly ILogger _logger; + + public MyService(ILogger logger) + { + _logger = logger; + } + + public void Initialize() + { + _logger.LogInformation("MyService has been initialized"); + } + } +} +```` + +Build the project, open the build folder, find the `MyPlugIn.dll`: + +![simple-plug-in-dll-file](images/simple-plug-in-dll-file.png) + +Copy `MyPlugIn.dll` into the plug-in folder (`D:\Temp\MyPlugIns` for this example). + +If you have configured the main application like described above (see Basic Usage section), you should see the `MyService has been initialized` log in the application startup. \ No newline at end of file diff --git a/docs/en/images/simple-plug-in-dll-file.png b/docs/en/images/simple-plug-in-dll-file.png new file mode 100644 index 0000000000..3155708d68 Binary files /dev/null and b/docs/en/images/simple-plug-in-dll-file.png differ diff --git a/docs/en/images/simple-plugin-library.png b/docs/en/images/simple-plugin-library.png new file mode 100644 index 0000000000..9fefd57dda Binary files /dev/null and b/docs/en/images/simple-plugin-library.png differ