104 lines
6.0 KiB
Markdown
104 lines
6.0 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Resources/TranslateExtension.cs
|
||
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/Resources/StringResources.Designer.cs
|
||
|
|
generated_at: "2026-04-16T11:13:28.138314+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "ea967aac84c55893"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: DTS.Viewer.Graph.Resources
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides localization infrastructure for the `DTS.Viewer.Graph` namespace. It enables XAML-based string localization through a WPF markup extension (`TranslateExtension`) backed by a strongly-typed resource class (`StringResources`). The resources defined here support user-facing messaging for chart operations, data filtering validation, and file export functionality (PDF/CSV).
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### `TranslateExtension` (class)
|
||
|
|
**Namespace:** `DTS.Viewer.Graph`
|
||
|
|
**Inheritance:** `System.Windows.Markup.MarkupExtension`
|
||
|
|
**Attribute:** `[MarkupExtensionReturnType(typeof(string))]`
|
||
|
|
|
||
|
|
A XAML markup extension that resolves localized strings from the resource manager at runtime.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `TranslateExtension(string key)` | Initializes the extension with the resource key to look up. The `key` parameter is stored in a readonly field `_key`. |
|
||
|
|
| Method | `override object ProvideValue(IServiceProvider serviceProvider)` | Returns the localized string for `_key` via `StringResources.ResourceManager.GetString(_key)`. Returns `NotFound` if `_key` is null or empty. Returns `NotFound + " " + _key` if the key is not found in resources. |
|
||
|
|
|
||
|
|
**Constants:**
|
||
|
|
- `private const string NotFound = "#stringnotfound#"` — Sentinel value returned when a resource key cannot be resolved.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### `StringResources` (class)
|
||
|
|
**Namespace:** `DTS.Viewer.Graph.Resources`
|
||
|
|
**Accessibility:** `internal`
|
||
|
|
**Attribute:** `[GeneratedCode]`, `[DebuggerNonUserCode]`, `[CompilerGenerated]`
|
||
|
|
|
||
|
|
An auto-generated strongly-typed resource class. Do not edit manually; regenerate from `.resx` file.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Property | `static ResourceManager ResourceManager` | Lazily initializes and returns a cached `ResourceManager` instance bound to `"DTS.Viewer.Graph.Resources.StringResources"`. |
|
||
|
|
| Property | `static CultureInfo Culture` | Gets or sets the culture used for resource lookups. Defaults to `null` (uses current thread's `CurrentUICulture`). |
|
||
|
|
|
||
|
|
**Resource String Properties (all `internal static string`):**
|
||
|
|
|
||
|
|
| Property Name | Purpose |
|
||
|
|
|---------------|---------|
|
||
|
|
| `BadDataFromCustomFilter` | Error message for filter frequency causing out-of-bounds data. Format placeholders: `{0}` (frequency), `{1}` (additional info). |
|
||
|
|
| `BadDataFromTestSetupDefaultFilter` | Error message for test setup default filter issues. Format placeholder: `{0}`. |
|
||
|
|
| `BadDataUnfilteredUnknown` | Error message for unviewable channel data. Format placeholder: `{0}`. |
|
||
|
|
| `ReadingChannelData` | Status message: "Reading channel data...." |
|
||
|
|
| `SavePDFError` | Error message for chart PDF save failure. |
|
||
|
|
| `SavePDFSuccess` | Success message for chart PDF save. Format placeholders: `{0}`, `{1}`, `{2}`, `{3}`. |
|
||
|
|
| `SaveReportCSVError` | Error message for report CSV save failure. |
|
||
|
|
| `SaveReportCSVSuccess` | Success message for report CSV save. Format placeholder: `{0}` (path). |
|
||
|
|
| `SaveReportPDFError` | Error message for report PDF save failure. |
|
||
|
|
| `SaveReportPDFSuccess` | Success message for report PDF save. Format placeholder: `{0}` (path). |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
1. **Key immutability:** `_key` in `TranslateExtension` is `readonly` and set only at construction.
|
||
|
|
2. **Non-null return:** `TranslateExtension.ProvideValue` never returns `null`. It always returns either a valid localized string or a `NotFound` sentinel (with optional key suffix).
|
||
|
|
3. **Fallback behavior:** If `StringResources.ResourceManager.GetString(_key)` returns `null`, the extension returns `"#stringnotfound# " + _key`.
|
||
|
|
4. **Empty key handling:** If `_key` is `null` or empty string, `ProvideValue` returns exactly `"#stringnotfound#"` without a trailing space or key.
|
||
|
|
5. **Auto-generation constraint:** `StringResources` class is tool-generated. Manual edits will be lost upon regeneration.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
**This module depends on:**
|
||
|
|
- `System` (core types)
|
||
|
|
- `System.Windows.Markup` (`MarkupExtension` base class, `MarkupExtensionReturnTypeAttribute`)
|
||
|
|
- `System.Resources` (`ResourceManager`)
|
||
|
|
- `System.Globalization` (`CultureInfo`)
|
||
|
|
- `System.CodeDom.Compiler` (`GeneratedCodeAttribute`)
|
||
|
|
- `System.Diagnostics` (`DebuggerNonUserCodeAttribute`)
|
||
|
|
- `System.Runtime.CompilerServices` (`CompilerGeneratedAttribute`)
|
||
|
|
|
||
|
|
**Dependents (inferred):**
|
||
|
|
- XAML files within `DTS.Viewer.Graph` that use `{x:Static}` or `{local:Translate}` markup extensions for localized strings.
|
||
|
|
- Code within `DTS.Viewer.Graph` that directly references `StringResources` properties for message formatting.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
1. **Sentinel value is private:** The `NotFound` constant is `private`, so consuming code cannot programmatically check if a lookup failed by comparing against the sentinel. The sentinel string `"#stringnotfound#"` is effectively hardcoded in behavior.
|
||
|
|
|
||
|
|
2. **Key leakage in fallback:** When a key is not found, the returned string includes the key name (`"#stringnotfound# " + _key`). This could expose internal resource key names to end users in production if keys are missing.
|
||
|
|
|
||
|
|
3. **Inconsistent fallback format:** Empty/null keys return `"#stringnotfound#"` (no trailing space), while missing keys return `"#stringnotfound# " + _key` (with space and key). This inconsistency may complicate string comparison or testing.
|
||
|
|
|
||
|
|
4. **Internal visibility:** `StringResources` is `internal`, so it cannot be accessed from outside the `DTS.Viewer.Graph` assembly. External assemblies must use `TranslateExtension` in XAML or have no access to these resources.
|
||
|
|
|
||
|
|
5. **Designer file coupling:** The `.resx` file backing `StringResources` is not included in the provided source. The actual string values and any additional resources are defined elsewhere and regenerated into this designer file.
|