Files
DP44/docs/ai/DataPRO/Modules/TestSetups/CachedItemsList/Resources.md
2026-04-17 14:55:32 -04:00

3.1 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/TestSetups/CachedItemsList/Resources/TranslateExtension.cs
DataPRO/Modules/TestSetups/CachedItemsList/Resources/StringResources.Designer.cs
2026-04-17T16:12:50.916382+00:00 zai-org/GLM-5-FP8 1 b004bb021a814472

Resources

1. Purpose

This module provides localization resources specifically for the CachedItemsList functionality within the TestSetups system. It enables XAML-based UI components to bind to localized strings via a markup extension and exposes strongly-typed string properties for keys such as "CacheTime", "Hardware", and "Sensor" for use in code-behind or other logic.

2. Public Interface

  • TranslateExtension (Class)
    • Signature: public class TranslateExtension : MarkupExtension
    • Constructor: TranslateExtension(string key) — Initializes the extension with the resource key to look up.
    • Method: public override object ProvideValue(IServiceProvider serviceProvider) — Returns the localized string corresponding to _key. Returns #stringnotfound# if the key is null/empty, or #stringnotfound# <key> if the lookup fails.
  • StringResources (Class)
    • Signature: internal class StringResources
    • Properties: Provides access to specific localized strings.
      • string CacheTime: Looks up "Cache Time".
      • string DBTime: Looks up "Db Time".
      • string Deleted: Looks up "[Deleted]".
      • string Hardware: Looks up "Hardware".
      • string Name: Looks up "Name".
      • string ObjectType: Looks up "(Type)".
      • string Prepare_TestSetups_EditTestSetup_Page_Update: Looks up "Refresh".
      • string Sensor: Looks up "Sensor".
      • string SensorCal: Looks up "Sensor calibration".
    • Property: static ResourceManager ResourceManager — Returns the cached resource manager for this assembly.
    • Property: static CultureInfo Culture — Gets or sets the current UI culture for resource lookups.

3. Invariants

  • TranslateExtension always returns a non-null string. It never returns null or throws exceptions for missing keys; it returns a fallback error string instead.
  • StringResources.ResourceManager is lazily initialized and cached; it is thread-safe upon initialization via the standard .NET pattern shown.
  • The StringResources class is internal and cannot be accessed outside the CachedItemsList assembly.

4. Dependencies

  • Depends on: System, System.Windows.Markup, System.Globalization, System.Resources.
  • Resource File: Implicitly depends on a .resx file (likely StringResources.resx) that generates the StringResources class.

5. Gotchas

  • The TranslateExtension swallows missing key errors silently in the UI by returning #stringnotfound#. This is useful for debugging but requires UI inspection to catch missing translations.
  • The constant NotFound is defined locally within TranslateExtension. If other modules use a similar pattern, the error string format is duplicated rather than shared.