5.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T14:12:42.546708+00:00 | zai-org/GLM-5-FP8 | 1 | 5a3256f83f5993a9 |
Documentation: DTS.Common.CPU Module
1. Purpose
This module serves as a Prism-based plugin module for CPU-related functionality within the DTS application framework. It registers the CPUEngine implementation with the Unity dependency injection container and provides assembly metadata (name and image) used by the main application shell to display available components. The module follows the Prism modularity pattern, allowing it to be dynamically loaded and initialized at runtime.
2. Public Interface
CPUModule Class
Signature:
[Export(typeof(IModule))]
[Module(ModuleName = "CPU")]
public class CPUModule : IModule
Constructor:
public CPUModule(IUnityContainer unityContainer)
Accepts an IUnityContainer instance via constructor injection and stores it in a private readonly field _unityContainer.
Methods:
public void Initialize()
Registers ICPUEngine mapped to CPUEngine with the Unity container. Contains a commented-out registration for IPropertyViewModel mapped to PropertyViewModel.
CPUNameAttribute Class
Signature:
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class CPUNameAttribute : TextAttribute
Constructors:
public CPUNameAttribute()
public CPUNameAttribute(string s)
Both constructors initialize _assemblyName to the hardcoded string "CPUAsssembly".
Properties:
public override string AssemblyName { get; }
Returns _assemblyName (value: "CPUAsssembly").
Methods:
public override Type GetAttributeType()
public override string GetAssemblyName()
GetAttributeType() returns typeof(TextAttribute). GetAssemblyName() returns the AssemblyName property value.
CUPImageAttribute Class
Signature:
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class CUPImageAttribute : ImageAttribute
Constructors:
public CUPImageAttribute()
public CUPImageAttribute(string s)
Both constructors initialize _img by calling AssemblyInfo.GetImage(AssemblyNames.CPU.ToString()).
Properties:
public override BitmapImage AssemblyImage { get; }
public override string AssemblyName { get; }
public override string AssemblyGroup { get; }
public override eAssemblyRegion AssemblyRegion { get; }
AssemblyImage: Lazily initializes and returns aBitmapImagefromAssemblyInfo.GetImage().AssemblyName: ReturnsAssemblyNames.CPU.ToString().AssemblyGroup: ReturnseAssemblyGroups.Viewer.ToString().AssemblyRegion: ReturnseAssemblyRegion.NotAssigned.
Methods:
public override Type GetAttributeType()
public override BitmapImage GetAssemblyImage()
public override string GetAssemblyName()
public override eAssemblyRegion GetAssemblyRegion()
public override string GetAssemblyGroup()
All return their corresponding property values. GetAttributeType() returns typeof(ImageAttribute).
3. Invariants
- The
_unityContainerfield is initialized only once via constructor injection and is never null after construction (assuming the DI container provides a valid instance). CPUNameAttributeandCUPImageAttributeare applied at the assembly level withAllowMultiple = false, meaning only one instance of each should exist per assembly.- The
AssemblyNameproperty inCPUNameAttributealways returns"CPUAsssembly"regardless of constructor arguments. - The
AssemblyGroupinCUPImageAttributeis alwayseAssemblyGroups.Viewer. - The
AssemblyRegioninCUPImageAttributeis alwayseAssemblyRegion.NotAssigned.
4. Dependencies
This module depends on:
System.Windows.Media.Imaging— ForBitmapImagetype.System.ComponentModel.Composition— For MEF[Export]attribute.Microsoft.Practices.Prism.Modularity— ForIModuleinterface and[Module]attribute.Microsoft.Practices.Unity— ForIUnityContainerinterface.DTS.Common.Interface— ForTextAttribute,ImageAttribute,ICPUEngine,AssemblyInfo,AssemblyNames,eAssemblyGroups, andeAssemblyRegion(inferred from usage).
What depends on this module:
- Cannot be determined from this source file alone. Likely consumed by a main application shell that scans for Prism modules and displays assembly metadata.
5. Gotchas
-
Typo in class name:
CUPImageAttributeappears to be a typo forCPUImageAttribute. The assembly attribute at line 9 is[assembly: CUPImage()]which matches this typo. -
Typo in assembly name string:
CPUNameAttributehardcodes_assemblyName = "CPUAsssembly"(note the double 's'). This may cause display issues or lookup failures if other code expects"CPUAssembly". -
Ignored constructor parameter: Both attribute classes accept a
string sparameter in their constructors but completely ignore it, always using hardcoded values instead. -
Commented-out registration: The
Initialize()method contains a commented-out registration forIPropertyViewModel. It is unclear whether this is intentional tech debt or deprecated functionality. -
Side effect in property getter: The
AssemblyImageproperty getter has a side effect—it assigns to_imgbefore returning. This is unusual for a property getter and could cause unexpected behavior if the property is accessed multiple times.