Skip to content

Read a preference value

This operation returns a cached preference value entirely from memory, without any database round-trip, using one of three Item indexer overloads to select the application/page/scope combination to search.

Field Value
Operation ID OP-PREF-002
Trigger Consumer code accesses instance(key), instance(key, scope), or instance(app, page, key)
Inputs Key (any object), optional PrefScope, optional explicit application/page
Outputs The stored preference value (Object) or Nothing if not found
Primary components clsPreferences.Item (three overloads)
Entry point SAIF.Presentation\clsPreferences.vb

Steps

  1. Normalize the key to a lower-case string (BR-PREF-002); if inKey is Nothing, return Nothing immediately.
  2. If inKey is Nothing: return Nothing without further processing.
  3. Look up the matching Preference group by ApplicationName (case-sensitive for the 2-argument overloads*, case-insensitive for the 3-argument overload) and Pagename (derived via PageKey(scope), which returns Page.ToLower() only for PageLevel scope, else empty string) (BR-PREF-001).
  4. If the group is found and contains the (lower-cased) key in PreferenceItems, return the value; otherwise return Nothing.
  5. If the group is not found: return Nothing.
  6. If the key is not present in PreferenceItems: return Nothing.

No business-rule validation or error branching occurs beyond the above.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Item indexer accessed]) --> S1{Key is Nothing?}
    S1 -->|Yes| EndNothing([Return Nothing])
    S1 -->|No| S2[Normalize key to lower-case]
    S2 --> S3[Find matching Preference group by app/page]
    S3 --> S4{Group found and key present?}
    S4 -->|Yes| EndValue([Return stored value])
    S4 -->|No| EndNothing2([Return Nothing])

Failure and edge-case behavior

  • A missing group or missing key both silently return Nothing; no exception or error signal distinguishes "not found" from other conditions.
  • The 2-argument Item overloads compare ApplicationName case-sensitively, while the 3-argument overload lowercases both ApplicationName and Pagename before comparing — an inconsistency in case-handling between overloads*.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Presentation\clsPreferences.vb