Table of Contents

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

IConfigurationSection

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

configBuilder IConfigurationBuilder
fileProvider IFileProvider
path string
optional bool
reloadOnChange bool

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

configBuilder IConfigurationBuilder
fileProvider IFileProvider
path string
optional bool
reloadOnChange bool

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

mapName string

Returns

string

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

steam64 CSteamID
fileName string
useMap bool
character byte

Returns

string

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

shorterPath DirectoryInfo
longerPath DirectoryInfo
includeSubDirectories bool

Returns

bool

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

shorterPath string
longerPath string
includeSubDirectories bool

Returns

bool

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

fileProvider IFileProvider
filePath string
onUpdated Action

Returns

IDisposable

Remarks

filePath must be in the Warfare folder.