Class DictConfigBase
Base class for JSON-backed configuration objects that expose dotted-key access.
Wraps a Newtonsoft.Json.Linq.JObject and provides thread-safe getters/setters and persistence.
Inheritance
object
DictConfigBase
Assembly: WSS_Core_Interface.dll
Syntax
public abstract class DictConfigBase
Constructors
DictConfigBase(string, JObject)
Initializes the configuration by loading a JSON file (or writing defaults when missing).
Declaration
protected DictConfigBase(string path, JObject defaults)
Parameters
| Type |
Name |
Description |
| string |
path |
Destination file path. Parent directory is created when needed.
|
| JObject |
defaults |
Default JSON content to save and use when the file does not exist.
|
Fields
_root
Root JSON object for this configuration.
Declaration
Field Value
_sync
Synchronization gate for JSON reads/writes.
Declaration
protected readonly object _sync
Field Value
Properties
Path
Resolved file path used for persistence.
Declaration
public string Path { get; }
Property Value
Methods
GetFloat(string, float)
Gets a float or returns a default when missing.
Declaration
public float GetFloat(string key, float dflt = 0)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| float |
dflt |
|
Returns
GetInt(string, int)
Gets an int or returns a default when missing.
Declaration
public int GetInt(string key, int dflt = 0)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| int |
dflt |
|
Returns
GetString(string, string)
Gets a string or returns a default when missing.
Declaration
public string GetString(string key, string dflt = "")
Parameters
| Type |
Name |
Description |
| string |
key |
|
| string |
dflt |
|
Returns
Save()
Persists the current JSON content to Path.
Declaration
Set(string, JToken)
Writes value at dottedKey, creating intermediate objects as needed.
Declaration
public void Set(string dottedKey, JToken value)
Parameters
| Type |
Name |
Description |
| string |
dottedKey |
Dotted key, e.g., "constants.PModeProportional".
|
| JToken |
value |
JSON token to assign.
|
TryGetFloat(string, out float)
Try to read a float from a dotted key.
Declaration
public bool TryGetFloat(string key, out float v)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| float |
v |
|
Returns
TryGetFloatArray(string, out float[])
Try to read a float array from a dotted key.
Declaration
public bool TryGetFloatArray(string key, out float[] arr)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| float[] |
arr |
|
Returns
TryGetInt(string, out int)
Try to read an int from a dotted key.
Declaration
public bool TryGetInt(string key, out int v)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| int |
v |
|
Returns
TryGetString(string, out string)
Try to read a string from a dotted key.
Declaration
public bool TryGetString(string key, out string s)
Parameters
| Type |
Name |
Description |
| string |
key |
|
| string |
s |
|
Returns