Persist preferences¶
This operation serializes every in-memory Preference record belonging to the store's current application to JSON and hands each one to SAIF.Framework.Preferences.PreferenceData.SavePreferences. This library issues no SQL; the write is executed entirely inside the SAIF.BOF.Framework package.
| Field | Value |
|---|---|
| Operation ID | OP-PRES-005 |
| Trigger | Consuming code calls Save() after a batch of Add / Remove / Clear calls |
| Inputs | The in-memory _Preferences list, m_DPI |
| Outputs | Persisted preference records; the function always returns False |
| Primary components | clsPreferences.Save |
| Entry point | SAIF.Presentation/clsPreferences.vb |
Steps¶
- Log method entry via
clsLogTrace.MethodBegin(). No SQL. - Construct
PreferenceData(m_DPI). - Delegates to
SAIF.Framework.Preferences; the framework's own persistence logic is not visible from this repository.** - Iterate
_Preferences, skipping any record whoseApplicationNamediffers from the store's current application (BR-PRES-020). - For each matching record, serialize
PreferenceItemsto JSON withJavaScriptSerializerwhen the dictionary is non-empty, or pass an empty string when it is empty (BR-PRES-021, BR-PRES-022). - Call
PreferenceData.SavePreferences(applicationName, pagename, m_DPI.UserID, json)(BR-PRES-023). - The write is executed inside the framework package; the SQL and target table are not visible from this repository.**
- On any exception, wrap and re-throw as
ApplicationException("Unable to save preferences.", ex)(BR-PRES-024). - Return
result, which is never assigned and is therefore alwaysFalse. - The trailing
clsLogTrace.MethodEnd()call afterReturn resultis unreachable — a verified defect in this library's source.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Save called]) --> S1[Log method entry]
S1 --> S2[Construct PreferenceData]
S2 --> S3[Iterate _Preferences]
S3 --> D1{ApplicationName matches current application?}
D1 -->|No| Skip[Skip record]
D1 -->|Yes| S4[Serialize PreferenceItems to JSON, or empty string]
S4 --> S5[PreferenceData.SavePreferences]
S5 --> D2{Exception thrown?}
D2 -->|Yes| Err([Wrap and re-throw ApplicationException])
D2 -->|No| Loop{More records?}
Loop -->|Yes| S3
Loop -->|No| EndOk([Return False, unreachable MethodEnd])
Skip --> Loop
Failure and edge-case behavior¶
- Any exception raised by
PreferenceData.SavePreferencesis wrapped and re-thrown asApplicationException("Unable to save preferences.", ex)(BR-PRES-024). Save()always returnsFalseeven on success, because theresultlocal is never assignedTrue— callers cannot use the return value to detect success; only a thrownApplicationExceptionsignals failure.
Related documentation¶
Note: Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
SAIF.Presentation/clsPreferences.vb