5.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T13:56:16.461808+00:00 | zai-org/GLM-5-FP8 | 1 | 8d340ea94a701586 |
Documentation: DTS.Viewer.ChartOptions Resources
1. Purpose
This module provides localization infrastructure for the DTS.Viewer.ChartOptions namespace. 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. This separates user-facing string management from application logic, supporting multi-language scenarios.
2. Public Interface
TranslateExtension (Class)
Namespace: DTS.Viewer.ChartOptions
Inheritance: System.Windows.Markup.MarkupExtension
This class enables XAML binding to localized resources.
-
Constructor
public TranslateExtension(string key): Initializes the extension with the resource key to look up.
-
Methods
public override object ProvideValue(IServiceProvider serviceProvider): Resolves the_keyprovided in the constructor to a localized string.- Returns the localized string if found.
- Returns
#stringnotfound#if the key is null or empty. - Returns
#stringnotfound# [key]if the lookup fails for a specific key.
StringResources (Class)
Namespace: DTS.Viewer.ChartOptions.Resources
Access Modifier: internal
A strongly-typed resource class auto-generated by Visual Studio. It provides static properties to access culture-specific string values.
-
Properties
internal static global::System.Resources.ResourceManager ResourceManager: Gets the cachedResourceManagerinstance for this assembly.internal static global::System.Globalization.CultureInfo Culture: Gets or sets the current UI culture used for resource lookups.
-
Resource String Properties (Static, Read-Only) The following properties return localized strings corresponding to specific UI elements:
ChartUnitTypeFilterOptions_TitleLockTMaxTMaxYMinTMinYRangeResetAllResetTSaveChartSaveToPDFTimeUnitType
3. Invariants
- Return Type Guarantee: The
TranslateExtensionclass is decorated with[MarkupExtensionReturnType(typeof(string))], guaranteeing thatProvideValuereturns astring(boxed asobject). - Non-Null Return:
TranslateExtension.ProvideValuewill never returnnull. It guarantees a return value even if the key is missing or invalid (returning a fallback error string). - Resource Manager Singleton:
StringResources.ResourceManageruses a lazy-initialization pattern; it creates theResourceManagerinstance only once and caches it in the private static fieldresourceMan. - Immutability of Key: Once
TranslateExtensionis constructed, the_keyfield isreadonlyand cannot be changed.
4. Dependencies
Internal Dependencies:
TranslateExtensiondepends entirely onStringResources.ResourceManagerto perform the actual string lookup.
External Dependencies:
System.Windows.Markup: Required forMarkupExtensionandIServiceProvider(implies this is a WPF module).System.Resources: Required forResourceManager.System.Globalization: Required forCultureInfo.
Downstream Dependencies:
- XAML files within the
DTS.Viewer.ChartOptionsmodule (or other modules referencing this namespace) depend onTranslateExtensionto display localized text (e.g., usage likely looks like{local:Translate KeyName}).
5. Gotchas
- Silent Failure Behavior:
TranslateExtensiondoes not throw exceptions for missing keys. Instead, it returns the literal string#stringnotfound#(for null/empty keys) or#stringnotfound# [key](for missing keys). This visual indicator might appear in the UI if resources are misconfigured, rather than causing a compile-time or runtime crash. - Auto-Generated Code:
StringResourcesis marked withGeneratedCodeAttribute. Manual edits to this file will be overwritten if the resource tooling regenerates it. The actual string values reside in an external.resxfile (likelyStringResources.resx) which is not visible in the provided source but is implied by the designer file. - Internal Visibility: The
StringResourcesclass isinternal. It cannot be accessed directly from outside theDTS.Viewer.ChartOptionsassembly. However,TranslateExtensionispublic, allowing external assemblies to use the XAML extension if they reference this assembly. - Case Sensitivity: The
ResourceManager.GetStringmethod called byTranslateExtensionis typically case-sensitive regarding the resource key (depending on the underlying resource set implementation), though the constant_keyis passed exactly as provided to the constructor.