6.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-17T15:58:02.305916+00:00 | zai-org/GLM-5-FP8 | 1 | 044fd045b3bc16bb |
Documentation: HardwareList Resources Module
1. Purpose
This module provides localization/internationalization support for the HardwareList component of the DataPRO system. It enables XAML-based UI elements to declaratively reference localized strings through a markup extension pattern, while the underlying resource class provides strongly-typed access to hardware-related display text (device names, column headers, action labels, etc.). The module abstracts the resource lookup mechanism, allowing UI code to reference string resources by key without direct interaction with ResourceManager.
2. Public Interface
TranslateExtension Class
Namespace: HardwareList
Inheritance: System.Windows.Markup.MarkupExtension
Attribute: [MarkupExtensionReturnType(typeof(string))]
| Member | Signature | Description |
|---|---|---|
| Constructor | TranslateExtension(string key) |
Initializes the extension with the resource key to look up. The key is stored in a readonly field _key. |
ProvideValue |
override object ProvideValue(IServiceProvider serviceProvider) |
Returns the localized string for the stored key. Returns #stringnotfound# if key is null/empty, or #stringnotfound# <key> if the key is not found in resources. |
StringResources Class
Namespace: HardwareList.Resources
Accessibility: internal
Attribute: Auto-generated by StronglyTypedResourceBuilder
| Member | Signature | Description |
|---|---|---|
ResourceManager |
static global::System.Resources.ResourceManager ResourceManager { get; } |
Returns the cached ResourceManager instance for the HardwareList.Resources.StringResources resource set. Lazily initialized on first access. |
Culture |
static global::System.Globalization.CultureInfo Culture { get; set; } |
Gets or sets the culture used for resource lookups. Overrides Thread.CurrentUICulture for this resource class. |
Static String Properties (selection):
| Property | Default Value (English) |
|---|---|
Add |
"Add" |
Remove |
"Remove" |
Replace |
"Replace" |
Swap |
"Swap" |
SerialNumber |
"Serial Number" |
Firmware |
"Firmware" |
IPAddress |
"IP Address" |
Port |
"Port" |
HardwareType |
"Type" |
ChannelCount |
"Channels" |
MaxSampleRate |
"Max Sample Rate" |
TestSampleRate |
"Test Sample Rate" |
CalDate |
"Cal Date" |
CalDueDate |
"Cal Due Date" |
FirstUseDate |
"First Use Date" |
Connection |
"Connection" |
USB |
"USB" |
CAN |
"CAN" |
UART |
"UART" |
PositionOnChain |
"Position on chain" |
IsHWClockMaster |
"Clock Master?" |
PTPDomain |
"PTP Domain" |
NotFound (constant in TranslateExtension) |
#stringnotfound# |
Hardware Device Name Properties (partial list):
| Property | Default Value |
|---|---|
SLICE_Base |
"SLICE" |
SLICE6_Base |
"SLICE 6" |
SLICE6_AIR |
"SLICE 6 AIR" |
SLICE2_Base |
"SLICE PRO SIM" |
SLICE2_DIM |
"SLICE PRO DIM" |
SLICE_IEPE |
"SLICE (IEPE)" |
SLICE_NANO_Base |
"SLICE (Nano)" |
SLICE_Micro_Base |
"SLICE (Micro)" |
SLICE1_5_Micro_Base |
"SLICE+" |
SLICE_Distributor |
"SLICE Distributor" |
SLICE_EthernetController |
"SLICE Ethernet Controller" |
TDAS_Pro_Rack |
"TDAS PRO Rack" |
TDAS_LabRack |
"TDAS PRO Lab Rack" |
G5VDS |
"G5 (VDS)" |
TSR_AIR |
"TSR AIR" |
Ribeye |
"Ribeye" |
PowerPro |
"PowerPRO Battery" |
3. Invariants
-
Key Immutability: The
_keyfield inTranslateExtensionisreadonlyand can only be set via the constructor. -
Error String Format: Missing translations always follow the pattern:
- Null/empty key →
#stringnotfound# - Key not found →
#stringnotfound# <key>(note the space before the key)
- Null/empty key →
-
Resource Manager Singleton: The
ResourceManagerproperty uses lazy initialization with a null-check pattern; once initialized, the same instance is returned for all subsequent calls. -
Auto-generation Constraint:
StringResourcesis marked withGeneratedCodeAttributeandCompilerGeneratedAttribute. Manual edits will be overwritten when the.resxfile is regenerated. -
Internal Visibility:
StringResourcesisinternal, restricting access to within the defining assembly.
4. Dependencies
This Module Depends On:
System(core types)System.Windows.Markup(MarkupExtensionbase class,MarkupExtensionReturnTypeAttribute)System.Resources(ResourceManagerfor resource lookup)System.Globalization(CultureInfofor culture-specific lookups)System.CodeDom.Compiler(attributes on generated code)System.ComponentModel(EditorBrowsableAttribute)System.Diagnostics(DebuggerNonUserCodeAttribute)System.Runtime.CompilerServices(CompilerGeneratedAttribute)
External Resource Dependency:
- A
.resxfile namedStringResources.resx(and culture-specific variants) must exist in theHardwareList.Resourcesnamespace at compile time.
What Depends On This Module:
- Inferred: Any XAML files in the
HardwareListmodule that use{local:Translate KeyName}syntax for localized strings. - Inferred: Code-behind files that reference
StringResources.<PropertyName>directly.
5. Gotchas
-
Silent Failure Pattern:
TranslateExtension.ProvideValuenever throws exceptions for missing keys. It returns error strings instead, which may appear directly in the UI. Consumers should test for the#stringnotfound#prefix if they need to detect missing translations programmatically. -
Culture Must Be Set Explicitly: The
StringResources.Cultureproperty allows overriding the current thread's UI culture. If set, all subsequent lookups use this culture until reset. This can cause unexpected language switches if not managed carefully. -
Auto-generated File Warning: The file header explicitly warns that changes to
StringResources.Designer.cswill be lost on regeneration. Developers must edit the underlying.resxfile instead. -
No Null Key Validation in Constructor:
TranslateExtensionaccepts null or empty keys without throwing; the validation only occurs inProvideValue(). This means XAML with{x:Null}or empty string bindings will compile but produce#stringnotfound#at runtime. -
Inconsistent Device Naming: Some device strings appear to have copy-paste errors in comments (e.g.,
SLICE2_Bridge_Hi,SLICE2_Bridge_Lo,SLICE2_IEPE_Hi,SLICE2_IEPE_Loall have summary comments saying "SLICE PRO SIM" rather than their actual device type). This is documentation debt in the auto-generated file, not a runtime issue.