Implementing the options pattern
With the options pattern, we use a plain class (sometimes called a POCO – Plain Old C# Object) to define a group of related options. Let's begin with how to define, configure, and use the configuration using the options pattern.
Defining an options class
An options class is a simple plain C# class. We can define an options class for the Azure SMS service as shown in the following code block:
public class AzureSmsServiceOptions { public string Sender { get; set; } public string ConnectionString { get; set; } }
It is a convention to add the Options
suffix to options classes. Once you define such a class, any module using this service can configure the options easily.
Configuring the options
As mentioned in the ABP modules section, you can configure the services of the dependent modules in the ConfigureServices
method of your module. We use the IServiceCollection.Configure
extension...