5.5 KiB
5.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T13:45:51.254810+00:00 | zai-org/GLM-5-FP8 | 1 | a6eff6c72a8470eb |
Documentation: DTS.Viewer.AddCalculatedChannel Module
1. Purpose
This module serves as the entry point for the "Add Calculated Channel" feature within the DTS Viewer application. It is responsible for self-registering its View and ViewModel components with the Unity dependency injection container and providing assembly-level metadata (such as display name, icon, and region assignment) to the main application shell for module discovery and UI composition.
2. Public Interface
AddCalculatedChannelModule
The main Prism module class responsible for dependency registration.
AddCalculatedChannelModule(IUnityContainer unityContainer)- Constructor that accepts an
IUnityContainerinstance via dependency injection and stores it in a private readonly field_unityContainer.
- Constructor that accepts an
void RegisterTypes(IContainerRegistry containerRegistry)- Implements
IModule.RegisterTypes. Calls the privateInitialize()method to perform type registrations.
- Implements
void OnInitialized(IContainerProvider containerProvider)- Implements
IModule.OnInitialized. Currently contains no implementation logic.
- Implements
AddCalculatedChannelModuleNameAttribute
An assembly-level attribute used to expose the module's name.
string AssemblyName { get; }- Returns the string representation of
AssemblyNames.AddCalculatedChannel.
- Returns the string representation of
Type GetAttributeType()- Returns
typeof(TextAttribute).
- Returns
string GetAssemblyName()- Returns the value of the
AssemblyNameproperty.
- Returns the value of the
AddCalculatedChannelModuleImageAttribute
An assembly-level attribute used to expose the module's image, group, and region metadata.
BitmapImage AssemblyImage { get; }- Retrieves the module's icon using
AssemblyInfo.GetImage.
- Retrieves the module's icon using
string AssemblyName { get; }- Returns the string representation of
AssemblyNames.AddCalculatedChannel.
- Returns the string representation of
string AssemblyGroup { get; }- Returns
eAssemblyGroups.Viewer.ToString().
- Returns
eAssemblyRegion AssemblyRegion { get; }- Returns
eAssemblyRegion.AddCalculatedChannelRegion.
- Returns
BitmapImage GetAssemblyImage()/string GetAssemblyName()/string GetAssemblyGroup()/eAssemblyRegion GetAssemblyRegion()- Accessor methods returning the values of their corresponding properties.
3. Invariants
- Naming Consistency: The
AssemblyNameproperty in both attribute classes must always resolve toAssemblyNames.AddCalculatedChannel.ToString(). - Region Assignment: The module is strictly assigned to the
eAssemblyRegion.AddCalculatedChannelRegionregion. - Group Assignment: The module belongs strictly to the
eAssemblyGroups.Viewergroup. - Registration Mapping: The
Initializemethod maps the interfaceIAddCalculatedChannelViewto the concrete implementationAddCalculatedChannelView, andIAddCalculatedChannelViewModeltoAddCalculatedChannelViewModel.
4. Dependencies
Internal Dependencies
DTS.Common: Used forAssemblyNames,eAssemblyGroups,eAssemblyRegion, andAssemblyInfo.DTS.Common.Interface: Provides the base classesTextAttributeandImageAttribute.DTS.Viewer.AddCalculatedChannel: The module references concrete typesAddCalculatedChannelViewandAddCalculatedChannelViewModeldefined within its own scope (though the file defining them is not provided here, they are referenced inInitialize).
External Dependencies
Prism.Ioc: ProvidesIContainerProviderandIContainerRegistry.Prism.Modularity: ProvidesIModuleandModuleAttribute.Unity: ProvidesIUnityContainer(used for specific Unity registration methods).System.Windows.Media.Imaging: ProvidesBitmapImagefor image handling.
5. Gotchas
- Misleading Singleton Comment: The comment in
Initialize()states: "Register View & View-Model with Unity dependency injection container as a singleton." However, the code uses_unityContainer.RegisterType<...>(). In Unity,RegisterTyperegisters a transient mapping (new instance per request) by default, not a singleton. To register as a singleton,ContainerControlledLifetimeManagershould be used. The code behavior contradicts the documentation. - Side Effects in Property Getters: In
AddCalculatedChannelModuleImageAttribute, the getter forAssemblyImagemodifies the private field_img(lazy initialization pattern inside a property getter). This is a side effect that could cause unexpected behavior if the property is accessed multiple times or inspected in a debugger, though the result is cached. - Unused Constructor Parameter: Both attribute classes define a constructor taking a
string s, but the parameter is never used inside the constructor body. This suggests the parameter exists solely to satisfy a reflection-based instantiation requirement or is legacy code. - Dual Registration Approach: The module uses
IUnityContainer(field injection) to callRegisterType, but theRegisterTypesmethod signature provides anIContainerRegistry. This mixes Prism's abstract container registry with the concrete Unity container. While valid if the backing container is Unity, it couples the module strictly to the Unity container rather than remaining container-agnostic.