Search Results for

    Show / Hide Table of Contents

    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
    StimParamsConfig
    ModelConfig
    Namespace: Wss.CoreModule
    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
    protected JObject _root
    Field Value
    Type Description
    JObject

    _sync

    Synchronization gate for JSON reads/writes.

    Declaration
    protected readonly object _sync
    Field Value
    Type Description
    object

    Properties

    Path

    Resolved file path used for persistence.

    Declaration
    public string Path { get; }
    Property Value
    Type Description
    string

    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
    Type Description
    float

    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
    Type Description
    int

    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
    Type Description
    string

    Save()

    Persists the current JSON content to Path.

    Declaration
    public void Save()

    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
    Type Description
    bool

    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
    Type Description
    bool

    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
    Type Description
    bool

    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
    Type Description
    bool
    In this article
    Back to top Generated by DocFX