init
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportResults/Resources/TranslateExtension.cs
|
||||
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportResults/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-16T11:02:06.405832+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "154eee0c947eb6d0"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.PSDReportResults.Resources
|
||||
|
||||
## 1. Purpose
|
||||
This module provides localization infrastructure for the PSD Report Results viewer component. It consists of a strongly-typed resource accessor class (`StringResources`) generated from a `.resx` file, and a XAML markup extension (`TranslateExtension`) that allows UI elements to bind directly to localized strings declaratively within XAML markup.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `TranslateExtension`
|
||||
**Location:** `DTS.Viewer.PSDReportResults.Resources.TranslateExtension`
|
||||
**Inheritance:** `System.Windows.Markup.MarkupExtension`
|
||||
|
||||
A XAML markup extension used to resolve localized strings at runtime.
|
||||
|
||||
* **Constructor**
|
||||
```csharp
|
||||
public TranslateExtension(string key)
|
||||
```
|
||||
Initializes the extension with the resource key to be looked up. The key is stored in a private readonly field `_key`.
|
||||
|
||||
* **Method: ProvideValue**
|
||||
```csharp
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
```
|
||||
Resolves the localized string for the key provided in the constructor.
|
||||
* Returns `NotFound` ("#stringnotfound#") if the `_key` is null or empty.
|
||||
* Retrieves the string using `StringResources.ResourceManager.GetString(_key)`.
|
||||
* Returns `NotFound + " " + _key` if the resource lookup returns null (key not found in resources).
|
||||
|
||||
### `StringResources`
|
||||
**Location:** `DTS.Viewer.PSDReportResults.Resources.StringResources`
|
||||
**Visibility:** `internal`
|
||||
|
||||
A strongly-typed resource class auto-generated by Visual Studio/ResGen. It provides access to localized strings defined in the associated `.resx` file.
|
||||
|
||||
* **Property: ResourceManager**
|
||||
```csharp
|
||||
internal static global::System.Resources.ResourceManager ResourceManager { get; }
|
||||
```
|
||||
Returns the cached `ResourceManager` instance for this assembly. It looks up resources named `"DTS.Viewer.PSDReportResults.Resources.StringResources"`.
|
||||
|
||||
* **Property: Culture**
|
||||
```csharp
|
||||
internal static global::System.Globalization.CultureInfo Culture { get; set; }
|
||||
```
|
||||
Gets or sets the current `CultureInfo` for resource lookups. Overrides the current thread's `CurrentUICulture` for this specific resource class.
|
||||
|
||||
* **Resource Properties (Static Strings)**
|
||||
The following static properties return localized strings:
|
||||
* `ChannelName` (Lookup key: "ChannelName")
|
||||
* `ExportPSDHeader` (Lookup key: "ExportPSDHeader")
|
||||
* `ExportPSDtoCSV` (Lookup key: "ExportPSDtoCSV")
|
||||
* `ExportPSDtoPDF` (Lookup key: "ExportPSDtoPDF")
|
||||
* `GRMS` (Lookup key: "GRMS")
|
||||
* `PSDResultsHeader` (Lookup key: "PSDResultsHeader")
|
||||
* `SampleRate` (Lookup key: "SampleRate")
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
* **Auto-generation:** The `StringResources` class is auto-generated. Manual modifications to `StringResources.Designer.cs` will be lost upon regeneration. Changes must be made to the underlying `.resx` file.
|
||||
* **Return Types:** `TranslateExtension` is decorated with `[MarkupExtensionReturnType(typeof(string))]`, guaranteeing that `ProvideValue` returns a string (or the fallback error string).
|
||||
* **Fallback Behavior:** `TranslateExtension` will never return `null`. It guarantees a string return, either the localized value or a specific error constant.
|
||||
* **Visibility:** `StringResources` is `internal`, restricting access to the `DTS.Viewer.PSDReportResults` assembly.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
* **Internal Dependencies:**
|
||||
* `TranslateExtension` depends entirely on `StringResources.ResourceManager` to perform lookups.
|
||||
* **External Dependencies (Framework):**
|
||||
* `System`
|
||||
* `System.Windows.Markup` (for `MarkupExtension` and `IServiceProvider`)
|
||||
* `System.Resources` (for `ResourceManager`)
|
||||
* `System.Globalization` (for `CultureInfo`)
|
||||
* `System.CodeDom.Compiler` (Attributes on `StringResources`)
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
* **Error String Variations:** The `TranslateExtension` returns different error strings depending on the failure mode.
|
||||
* If the input `_key` is null/empty, it returns exactly `"#stringnotfound#"`.
|
||||
* If the lookup fails (key is valid but missing in resources), it returns `"#stringnotfound# " + _key` (note the space and the appended key).
|
||||
* Developers parsing or validating these strings must account for this difference.
|
||||
* **Designer File Edits:** As noted in the auto-generated header, editing `StringResources.Designer.cs` directly is unsafe. The specific resource strings listed (e.g., `ChannelName`, `GRMS`) are the only ones currently defined; adding new ones requires regenerating this file.
|
||||
* **Culture Management:** `StringResources.Culture` is a static property. Setting it changes the culture for all subsequent lookups within this resource manager, potentially affecting threading behavior if not managed carefully.
|
||||
Reference in New Issue
Block a user