swiftlys2/docs/api/releases/features/ai/
API Reference › Services

IPluginConfigurationService

Interface
Namespace: SwiftlyS2.Shared.Services · Assembly: SwiftlyS2.CS2.dll
public interface IPluginConfigurationService
View source

Properties

BasePath

Get the base path of plugin configuration.

string BasePath { get; }
Property Value

BasePathExists

Whether the base path exists in the file system.

bool BasePathExists { get; }
Property Value

Manager

Get the configuration root.

IConfigurationManager Manager { get; }
Property Value

Methods

Configure(Action<IConfigurationBuilder>)

Configure the internal configuration manager.

IPluginConfigurationService Configure(Action<IConfigurationBuilder> configure)
Parameters
Returns
The plugin configuration service.

GetConfigPath(string)

Get the path to the configuration file.

string GetConfigPath(string name)
Parameters
  • namestringThe name of the configuration file, including the extension.
Returns
The path to the configuration file.

InitializeJsonWithModel<T>(string, string)

Initialize the json configuration file with a class as template. When the file name ends with .jsonc , properties and fields marked with DescriptionAttribute are written with their description as // comment lines above the key, including members of nested objects, list items and dictionary values. A .json file is always written as plain JSON, since comments are not valid JSON.

IPluginConfigurationService InitializeJsonWithModel<T>(string name, string sectionName) where T : class, new()
Parameters
  • namestringThe name of the configuration file.
  • sectionNamestringThe name of the section in the configuration file.

InitializeJsonWithModel<T>(string, string, bool)

Initialize the json configuration file with a class as template. Behaves like String) when the file does not exist yet. When the file exists and addMissingKeys is true , keys present in the model but missing from the file are inserted with their default value, including keys of nested objects. In a .jsonc file each inserted key gets its DescriptionAttribute as // comment lines above it. The rest of the file, including existing values, comments and formatting, is left untouched. Dictionary entries and list items are never added. Keys are matched case-insensitively, the same way the configuration binder reads them. A file that is not valid JSON is not changed.

IPluginConfigurationService InitializeJsonWithModel<T>(string name, string sectionName, bool addMissingKeys) where T : class, new()
Parameters
  • namestringThe name of the configuration file.
  • sectionNamestringThe name of the section in the configuration file.
  • addMissingKeysboolWhether to insert keys missing from an existing file.

InitializeTomlWithModel<T>(string, string)

Initialize the TOML configuration file with a class as template. Properties and fields marked with DescriptionAttribute are written with their description as # comment lines above the key or above the table header. Members of inline tables cannot carry comments.

IPluginConfigurationService InitializeTomlWithModel<T>(string name, string sectionName) where T : class, new()
Parameters
  • namestringThe name of the configuration file.
  • sectionNamestringThe name of the section in the configuration file.

InitializeTomlWithModel<T>(string, string, bool)

Initialize the TOML configuration file with a class as template. Behaves like String) when the file does not exist yet. When the file exists and addMissingKeys is true , keys present in the model but missing from an existing table are inserted after the table's last value, and tables missing from the file are appended at its end, each with its DescriptionAttribute as # comment lines. The rest of the file, including existing values, comments and formatting, is left untouched. Members of inline tables and entries of table arrays are never added. Keys are matched case-insensitively, the same way the configuration binder reads them. A file that is not valid TOML is not changed.

IPluginConfigurationService InitializeTomlWithModel<T>(string name, string sectionName, bool addMissingKeys) where T : class, new()
Parameters
  • namestringThe name of the configuration file.
  • sectionNamestringThe name of the section in the configuration file.
  • addMissingKeysboolWhether to insert keys missing from an existing file.

InitializeWithTemplate(string, string)

Initialize the configuration file with a template. To use this, you must package a templates folder in the plugin, with the template file in it.

IPluginConfigurationService InitializeWithTemplate(string name, string templateName)
Parameters
  • namestringThe name of the configuration file.
  • templateNamestringThe name of the template file.