Browse Source

Add notes to the `Module-Development-Basics`

pull/12291/head
maliming 5 years ago
parent
commit
14373bb559
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 14
      docs/en/Module-Development-Basics.md

14
docs/en/Module-Development-Basics.md

@ -29,6 +29,8 @@ public class BlogModule : AbpModule
``ConfigureServices`` is the main method to add your services to the dependency injection system and configure other modules. Example: ``ConfigureServices`` is the main method to add your services to the dependency injection system and configure other modules. Example:
> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones.
````C# ````C#
public class BlogModule : AbpModule public class BlogModule : AbpModule
{ {
@ -63,6 +65,8 @@ See the [Configuration](Configuration.md) document for more about the configurat
``AbpModule`` class also defines ``PreConfigureServices`` and ``PostConfigureServices`` methods to override and write your code just before and just after ``ConfigureServices``. Notice that the code you have written into these methods will be executed before/after the ``ConfigureServices`` methods of all other modules. ``AbpModule`` class also defines ``PreConfigureServices`` and ``PostConfigureServices`` methods to override and write your code just before and just after ``ConfigureServices``. Notice that the code you have written into these methods will be executed before/after the ``ConfigureServices`` methods of all other modules.
> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones.
### Application Initialization ### Application Initialization
Once all the services of all modules are configured, the application starts by initializing all modules. In this phase, you can resolve services from ``IServiceProvider`` since it's ready and available. Once all the services of all modules are configured, the application starts by initializing all modules. In this phase, you can resolve services from ``IServiceProvider`` since it's ready and available.
@ -71,10 +75,18 @@ Once all the services of all modules are configured, the application starts by i
You can override ``OnApplicationInitialization`` method to execute code while application is being started. Example: You can override ``OnApplicationInitialization`` method to execute code while application is being started. Example:
> These methods have Async versions too, and if you want to make asynchronous calls inside these methods, override the asynchronous versions instead of the synchronous ones.
````C# ````C#
public class BlogModule : AbpModule public class BlogModule : AbpModule
{ {
//... // Asynchronous methods call synchronous methods by default, You only need to implement one of them.
public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
var myService = context.ServiceProvider.GetService<MyService>();
await myService.DoSomethingAsync();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{ {

Loading…
Cancel
Save