Add or update a preference value¶
This operation upserts a single preference key/value pair into the in-memory Preference set. The change is not persisted until Persist preferences runs.
| Field | Value |
|---|---|
| Operation ID | OP-PRES-003 |
| Trigger | Consuming code calls Add(inKey, inValue) or Add(inKey, inValue, inScope) |
| Inputs | Key, value, optional PrefScope (defaults to PageLevel) |
| Outputs | Mutated in-memory Preference record |
| Primary components | clsPreferences.Add (two overloads) |
| Entry point | SAIF.Presentation/clsPreferences.vb |
Steps¶
- Return silently if the key is
Nothing(BR-PRES-006). - Lower-case the key (BR-PRES-007).
- Locate the
Preferencerecord for the current application + resolved page key. - If none exists: create a new
Preference, set itsApplicationNameandPagename, and append it to the list (BR-PRES-013). - If the key already exists in
PreferenceItems, remove it first, then add the new value asinValue.ToString()(BR-PRES-014, BR-PRES-015).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Add key, value, scope]) --> D1{Key is Nothing?}
D1 -->|Yes| EndNoop([Return, no-op])
D1 -->|No| S1[Lower-case key]
S1 --> S2[Locate matching Preference record]
S2 --> D2{Record exists?}
D2 -->|No| S3[Create new Preference record and append]
D2 -->|Yes| S4[Use existing record]
S3 --> S5
S4 --> S5[Key already present?]
S5 -->|Yes| S6[Remove existing item]
S5 -->|No| S7[Add new item]
S6 --> S7
S7 --> EndOk([In-memory record updated])
Failure and edge-case behavior¶
- A
Nothingkey is a silent no-op rather than an error (BR-PRES-006). - The change is in-memory only — nothing is persisted until Persist preferences runs (BR-PRES-019).
Related documentation¶
Sources¶
SAIF.Presentation/clsPreferences.vb