Plugin settings are special classes that hold the configuration settings about our plugin. The following document explains how we can create and save settings.
Creating plugin settings
To create settings for our plugin, create a class that implements the interface EvenCart.Core.Config.ISettingGroup
. Any class that implements this interface becomes a settings class that can be injected and resolved.
For example, if we are creating an OAuth server based authentication plugin, our setting file could look like as follows.
using EvenCart.Core.Config;
namespace EvenCart.Authentication.OAuthServer
{
public class OAuthServerSettings : ISettingGroup
{
public string ClientId { get; set; }
public string ClientSecret { get; set; }
public string RedirectUrl { get; set; }
}
}
When EvenCart app starts, it scans for all the classes implementing ISettingGroup
interface and automatically registers them with the dependency container. The setting class then can be [injected or resolved]() just like any other service.
Saving plugin settings
The service interface EvenCart.Services.Settings.ISettingService
is used for saving settings. we can inject or resolve ISettingService
and call it's Save
method to save settings to database.
_settingService.Save(new OAuthServerSettings(){
ClientId = "123546",
ClientSecret = "JKLJ%^&UIOPEW",
RedirectUrl = "https://mydomain.com/"
});
Next steps
Congrats! We now understand the concepts needed to create our plugins. Next step would be to select the type of plugin we want to create.