Class ConfigurationHelper
- Namespace
- Uncreated.Warfare.Configuration
- Assembly
- Uncreated.Warfare.dll
public static class ConfigurationHelper
- Inheritance
-
ConfigurationHelper
- Inherited Members
Properties
EmptySection
An empty configuration section.
public static IConfigurationSection EmptySection { get; }
Property Value
Methods
AddJsonOrYamlFile(IConfigurationBuilder, IFileProvider, string, bool, bool)
Add a file source as either a JSON or YAML file, depending on the file extension.
public static void AddJsonOrYamlFile(IConfigurationBuilder configBuilder, IFileProvider fileProvider, string path, bool optional = false, bool reloadOnChange = false)
Parameters
configBuilderIConfigurationBuilderfileProviderIFileProviderpathstringoptionalboolreloadOnChangebool
AddSourceWithMapOverride(IConfigurationBuilder, IFileProvider, string, bool, bool)
Adds a new FileConfigurationSource at path with an optional file source with the map name appended.
public static void AddSourceWithMapOverride(IConfigurationBuilder configBuilder, IFileProvider fileProvider, string path, bool optional = false, bool reloadOnChange = true)
Parameters
configBuilderIConfigurationBuilderfileProviderIFileProviderpathstringoptionalboolreloadOnChangebool
Remarks
Example: Config.json and Config.Washington.json.
CleanFileName(string?)
Fixes a file name (without its extension) to remove invalid characters.
public static string? CleanFileName(string? mapName)
Parameters
mapNamestring
Returns
GetPlayerFilePath(CSteamID, string, bool, byte)
Returns the full path to a player's config folder combined with a fileName.
[Pure]
public static string GetPlayerFilePath(CSteamID steam64, string fileName, bool useMap = false, byte character = 0)
Parameters
Returns
IsChildOf(DirectoryInfo, DirectoryInfo, bool)
Checks to see if longerPath is a child folder or file of the directory shorterPath.
[Pure]
public static bool IsChildOf(DirectoryInfo shorterPath, DirectoryInfo longerPath, bool includeSubDirectories = true)
Parameters
shorterPathDirectoryInfolongerPathDirectoryInfoincludeSubDirectoriesbool
Returns
IsChildOf(string?, string, bool)
Checks to see if longerPath is a child folder or file of the directory shorterPath.
[Pure]
public static bool IsChildOf(string? shorterPath, string longerPath, bool includeSubDirectories = true)
Parameters
Returns
ListenForFileUpdate(IFileProvider, string, Action)
Watches for file updates on filePath, and invokes onUpdated when there is an update.
[MustUseReturnValue]
[Pure]
public static IDisposable ListenForFileUpdate(IFileProvider fileProvider, string filePath, Action onUpdated)
Parameters
fileProviderIFileProviderfilePathstringonUpdatedAction
Returns
Remarks
filePath must be in the Warfare folder.