init
This commit is contained in:
109
enriched-qwen3-coder-next/DataPRO/DbAPIUI/DbAPIUI/DbAPIUI.md
Normal file
109
enriched-qwen3-coder-next/DataPRO/DbAPIUI/DbAPIUI/DbAPIUI.md
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Program.cs
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/DoEverythingSample.cs
|
||||
generated_at: "2026-04-16T03:53:48.893244+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "db8eddd5ee513ff9"
|
||||
---
|
||||
|
||||
# DbAPIUI
|
||||
|
||||
## Documentation: `DoEverythingSample` Module
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module (`DoEverythingSample`) serves as a **demonstration and integration test harness** for core database operations in the DbAPIUI application. It programmatically performs a full end-to-end workflow: connecting to a local SQL Server LocalDB instance, logging in as an admin user, creating test sensors and calibrations, registering a Data Acquisition System (DAS), defining groups and channels, and setting up a test setup record. Its purpose is to validate DbAPI interactions and provide a reference implementation for developers integrating with the database layer—*not* as production logic.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `public class DoEverythingSample`
|
||||
|
||||
A self-contained sample class that executes a sequence of database operations via the `DbAPI` static facade.
|
||||
|
||||
##### `public void Start()`
|
||||
- **Behavior**: Initiates the `Connect()` method asynchronously on a background thread (`Task.Run`). This starts the full workflow: DB connection → login → sensor/group/DAS/test setup creation.
|
||||
- **Note**: No return value; success/failure is logged only.
|
||||
|
||||
##### Private Methods (Called Internally by `Start()`)
|
||||
|
||||
| Method | Signature | Behavior |
|
||||
|--------|-----------|----------|
|
||||
| `Connect()` | `private void Connect()` | Constructs a `ConnectionDetailsEx` object, sets paths for DB files (`db\`) and SQL scripts (`SQL Server Scripts\`), and calls `DbAPI.DbAPI.Connections.ConnectToDb`. On success, calls `Login()`. |
|
||||
| `Login()` | `private void Login()` | Calls `DbAPI.DbAPI.Connections.LoginUser` with hardcoded credentials (`"Admin"`, `"DTSAdmin"`). On success, stores the `IUserDbRecord` and calls `AddSensors()`. |
|
||||
| `AddSensors()` | `private void AddSensors()` | Clears internal sensor/calibration collections, then loops 3 times calling `CreateSensorAndCal` to create 3 analog sensors with calibrations. On success, calls `CreateDAS()`. |
|
||||
| `CreateDAS()` | `private void CreateDAS()` | Retrieves a DAS template (`"SLICEPRO Prototype"`), clones it, sets new properties (`SerialNumber = "SPS0001"`, `DASId = -1`), inserts it via `DASInsert`, then inserts its channels via `DASChannelsInsert`. On success, calls `CreateGroups()`. |
|
||||
| `CreateGroups()` | `private void CreateGroups()` | Creates a static group (`"MyStaticGroup"`), inserts it, associates it with the DAS via `GroupHardwareInsert`, creates channels, inserts group+channels, then creates a second (non-static) group, inserts it, and links it to a test setup via `TestSetupGroupsInsert` and `TestSetupHardwareInsert`. |
|
||||
| `CreateTestSetup()` | `private bool CreateTestSetup()` | Constructs and configures a `TestSetupRecord` with many properties set (e.g., `SamplesPerSecondAggregate = 20000`, `RecordingMode = CircularBuffer`, `TriggerCheckStep = true`). Calls `DbAPI.DbAPI.TestSetups.TestSetupsUpdateInsert`. On success, stores `_test`. Returns `true` on success. |
|
||||
| `InsertGroupAndChannels(...)` | `private bool InsertGroupAndChannels(ref IGroupDbRecord group, IChannelDbRecord[] channels)` | Inserts a group via `GroupsInsert`, then inserts associated hardware via `GroupHardwareInsert`, then inserts each channel via `ChannelsInsert`. Returns `false` on first failure. |
|
||||
| `CreateGroupChannels(...)` | `private bool CreateGroupChannels(ref IGroupDbRecord group, out IChannelDbRecord[] channels)` | Creates one `ChannelDbRecord` per sensor (via `CreateChannel`) and returns them as an array. |
|
||||
| `CreateChannel(int index)` | `private IChannelDbRecord CreateChannel(int index)` | Returns a new `ChannelDbRecord` with properties derived from `_Das` and `_sensors[index]` (e.g., `SensorId`, `DASChannelIndex`, `UserChannelName`). |
|
||||
| `CreateGroup(...)` | `private IGroupDbRecord CreateGroup(string serialNumber, string displayName, bool embedded)` | Returns a new `GroupDbRecord` with `SerialNumber`, `DisplayName`, `Embedded`, and metadata fields set. |
|
||||
| `CreateSensorAndCal(...)` | `private bool CreateSensorAndCal(string serialNumber, string comment, int capacity)` | Calls `CreateAnalogSensor`, inserts it via `SensorsAnalogUpdateInsert`, then creates and inserts a calibration via `SensorCalibrationsInsert`. Stores both in `_sensors` and `_calRecords`. Returns `false` on failure. |
|
||||
| `CreateAnalogSensor(...)` | `private IAnalogDbRecord CreateAnalogSensor(string serialNumber, string description, int capacity)` | Returns a new `AnalogDbRecord` with fixed properties (e.g., `Bridge = FullBridge`, `Model = "Generic Sensor"`, `SupportedExcitation = Volt5`). |
|
||||
| `CreateAnalogSensorCalibration(...)` | `private ISensorCalDbRecord CreateAnalogSensorCalibration(IAnalogDbRecord sensor)` | Returns a `SensorCalDbRecord` with fixed calibration metadata (e.g., `IsProportional = true`, `ZeroMethods = AverageOverTime`, `Records = [single CalibrationRecord]`). |
|
||||
| `GenerateCalibrationRecord()` | `private ICalibrationRecord GenerateCalibrationRecord()` | Returns a single `CalibrationRecord` with `Sensitivity = 0.2`, `SensitivityUnits = mVperVperEU`, `Excitation = Volt5`, `EngineeringUnits = "G"`. |
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- **Hardcoded Paths**: The module assumes the presence of two directories: `"db"` and `"SQL Server Scripts"` (relative to the working directory). If missing, only partial `ConnectionDetailsEx` is populated.
|
||||
- **User Credentials**: Login uses fixed credentials: username `"Admin"`, password `"DTSAdmin"`. No user input or configuration.
|
||||
- **DAS Template**: `CreateDAS()` relies on `DbAPI.DbAPI.DAS.DASGet` returning at least one record matching `"SLICEPRO Prototype"` and `"Prototype"`; otherwise, it aborts.
|
||||
- **Sensor Count**: Exactly 3 sensors are created; channel count matches sensor count.
|
||||
- **DAS Serial Number**: After cloning, the DAS serial number is overwritten to `"SPS0001"`; original template serial number is discarded.
|
||||
- **Group Hierarchy**: One static group is created first; a second group is created with `StaticGroupId` set to the first group’s ID.
|
||||
- **Test Setup Name**: The created test setup is always named `"MyTestSetup"`.
|
||||
- **No Rollback**: All operations are sequential and non-transactional; partial failures leave the database in an inconsistent state.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Internal Dependencies (from source):
|
||||
- **`DbAPI` static facade**: Specifically:
|
||||
- `DbAPI.DbAPI.Connections.ConnectToDb`, `LoginUser`
|
||||
- `DbAPI.DbAPI.Sensors.SensorsAnalogUpdateInsert`, `SensorCalibrationsInsert`
|
||||
- `DbAPI.DbAPI.DAS.DASGet`, `DASInsert`, `DASChannelsGet`, `DASChannelsInsert`
|
||||
- `DbAPI.DbAPI.Groups.GroupsInsert`
|
||||
- `DbAPI.DbAPI.GroupHardware.GroupHardwareInsert`
|
||||
- `DbAPI.DbAPI.Channels.ChannelsInsert`
|
||||
- `DbAPI.DbAPI.TestSetups.TestSetupsUpdateInsert`, `TestSetupGroupsInsert`, `TestSetupHardwareInsert`
|
||||
- **`DTS.Common.*` types**:
|
||||
- `ConnectionDetailsEx`, `IUserDbRecord`, `IAnalogDbRecord`, `ISensorCalDbRecord`, `IDASDBRecord`, `IDASChannelDBRecord`, `IGroupDbRecord`, `IChannelDbRecord`, `ITestSetupRecord`, `ICalibrationRecord`
|
||||
- Enums: `ExcitationVoltageOption`, `RecordingModes`, `CalibrationBehaviors`, `ZeroMethodType`, `InitialOffsetTypes`, `SensorConstants.SensUnits`
|
||||
- Classes: `InitialOffsets`, `InitialOffset`, `ZeroMethods`, `ZeroMethod`, `FilterClass`, `CalibrationRecords`, `CalibrationRecord`
|
||||
- **Logging infrastructure**:
|
||||
- `DbAPIUI.Logging.LogManager` (wraps `DTS.Common.Utilities.Logging.LogManager`)
|
||||
- Uses `TraceEventType` and `LogManager.LogEvents` (e.g., `LogEvents.Connections`, `LogEvents.Sensors`)
|
||||
|
||||
#### External Dependencies (inferred):
|
||||
- **SQL Server LocalDB**: Required for `ConnectionDetailsEx.GetSqlServerLocalDbPath()` and `AttachDBs.bat`.
|
||||
- **ODBC Tools**: Required for `DTS.Common.Utils.Database.GetODBCToolsPath`.
|
||||
- **Windows Forms**: `Program.cs` launches `Form1`, but `DoEverythingSample` itself is UI-agnostic.
|
||||
|
||||
#### What Depends on This Module?
|
||||
- Not referenced in the provided source. Likely used in tests or as a standalone sample runner (e.g., invoked from `Form1` or a test harness).
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **Hardcoded Credentials**: Login uses `"Admin"/"DTSAdmin"`—not suitable for production or shared environments.
|
||||
- **No Error Propagation**: `Start()` and all private methods log errors but do *not* throw exceptions or expose failure to callers. Consumers cannot programmatically detect success/failure.
|
||||
- **Race Condition Risk**: `Start()` uses `Task.Run` without synchronization; if called multiple times, concurrent DB writes may cause conflicts.
|
||||
- **Path Assumptions**: `"db"` and `"SQL Server Scripts"` are relative paths; behavior changes if working directory differs.
|
||||
- **Hardcoded DAS Serial**: Overwrites `SerialNumber = "SPS0001"` unconditionally; may conflict with existing hardware.
|
||||
- **Calibration Record Simplicity**: Only one calibration point is generated (`GenerateCalibrationRecord`), which may not reflect real-world multi-point calibrations.
|
||||
- **Missing Null Checks**: `CreateDAS()` uses `records.First()` without verifying `records.Length > 0` *before* indexing (though `hr` check follows).
|
||||
- **`_Das` Field Initialization**: `_Das` is set *only* if `DASInsert` succeeds; subsequent methods (`CreateGroups`) assume `_Das != null`, but no guard is present.
|
||||
- **`TestSetupRecord` Initialization**: Many properties are set to default values (e.g., `ISFFile = ""`, `CustomerDetails = ""`); behavior may differ if defaults change in the API.
|
||||
- **No Cleanup**: No rollback or deletion logic; repeated runs will insert duplicate records unless IDs are reset (e.g., `DASId = -1` triggers insert, not update).
|
||||
|
||||
None identified beyond those listed above.
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Connections/LoggedInUser.cs
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Connections/ConnectionDetailsEx.cs
|
||||
generated_at: "2026-04-16T03:53:38.132462+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "cc95046c6aba3290"
|
||||
---
|
||||
|
||||
# Connections
|
||||
|
||||
## Documentation: `DbAPIUI.Connections` Module
|
||||
|
||||
---
|
||||
|
||||
### 1. Purpose
|
||||
|
||||
This module provides UI-specific extensions and abstractions for database connection management within the `DbAPIUI` layer. It encapsulates user authentication state via `LoggedInUser` and enriches connection configuration with UI-friendly properties and helper utilities in `ConnectionDetailsEx`. Its role is to bridge low-level database connection contracts (e.g., `IUserDbRecord`, `IConnectionDetails`) with Windows UI conventions—such as password masking, folder/file pickers, and registry-based SQL Server LocalDB discovery—enabling consistent and secure interaction with database resources in desktop UI contexts.
|
||||
|
||||
---
|
||||
|
||||
### 2. Public Interface
|
||||
|
||||
#### `class LoggedInUser`
|
||||
- **Namespace**: `DbAPIUI.Connections`
|
||||
- **Purpose**: Represents a logged-in user session, bundling user identity and connection metadata.
|
||||
- **Properties**:
|
||||
- `Tuple<IUserDbRecord, IConnectionDetails> Details { get; set; }`
|
||||
Holds the authenticated user’s database record (`IUserDbRecord`) and associated connection configuration (`IConnectionDetails`). Both components are required and non-null for valid state.
|
||||
- **Methods**:
|
||||
- `override string ToString()`
|
||||
Returns a formatted string: `<connection-details-username>\\<user-display-name>`, where `connection-details-username` is derived from `Details.Item2` (e.g., `DbUser` field of `IConnectionDetails`) and `user-display-name` from `Details.Item1.DisplayName`.
|
||||
|
||||
#### `class ConnectionDetailsEx`
|
||||
- **Namespace**: `DbAPIUI`
|
||||
- **Base Type**: Inherits from `DbAPI.Connections.ConnectionDetails` (assumed abstract/base class; not shown).
|
||||
- **Purpose**: Extends base connection details with UI-specific attributes and helper logic for local SQL Server LocalDB setup.
|
||||
- **Properties**:
|
||||
- `override string DbUserPassword { get; set; } = "DTSSealBeachHQ"`
|
||||
Password for database authentication. Marked with `[PasswordPropertyText(true)]` to signal UI controls to mask input.
|
||||
- `override string DbFolderPath { get; set; } = ""`
|
||||
Path to the database folder. Marked with `[Editor(typeof(FolderNameEditor), ...)]` to enable folder browser dialog in UI designers.
|
||||
- `override string AttachDbsBatPath { get; set; } = ""`
|
||||
Path to a batch file used for attaching databases. Marked with `[Editor(typeof(FileNameEditor), ...)]` to enable file picker dialog in UI designers.
|
||||
- **Methods**:
|
||||
- `static string GetSqlServerLocalDbPath()`
|
||||
Queries the Windows Registry (`HKLM\SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Installed Versions`) to locate the highest installed SQL Server LocalDB version’s installation directory. Returns the path with `"LocalDB"` replaced by `"Tools"` (e.g., `C:\Program Files\Microsoft SQL Server\150\Tools\`). Returns `string.Empty` if no valid installation is found.
|
||||
|
||||
---
|
||||
|
||||
### 3. Invariants
|
||||
|
||||
- `LoggedInUser.Details` must be non-null and contain non-null `Item1` (`IUserDbRecord`) and `Item2` (`IConnectionDetails`) for the object to represent a valid logged-in state. Violation results in undefined behavior in `ToString()` (e.g., `NullReferenceException`).
|
||||
- `ConnectionDetailsEx.DbUserPassword` defaults to `"DTSSealBeachHQ"`; this is a hardcoded fallback and should not be used in production without explicit override.
|
||||
- `ConnectionDetailsEx.GetSqlServerLocalDbPath()` assumes:
|
||||
- SQL Server LocalDB is installed under the specified registry path.
|
||||
- Subkey names are parseable as `double` (version numbers).
|
||||
- The `InstanceAPIPath` value ends with `"SqlUserInstance.dll"` (validated before path extraction).
|
||||
- If any of these assumptions fail, the method silently skips the subkey and continues; no exception is thrown.
|
||||
|
||||
---
|
||||
|
||||
### 4. Dependencies
|
||||
|
||||
#### Imports/References:
|
||||
- `DbAPI.Connections` (namespace): Provides `IUserDbRecord`, `IConnectionDetails`, and base `ConnectionDetails` class.
|
||||
- `DTS.Common.Interface.Database`: Provides `IUserDbRecord` (likely shared interface for database user records).
|
||||
- `Microsoft.Win32`: Used for registry access in `GetSqlServerLocalDbPath()`.
|
||||
- `System.ComponentModel`: Provides `PasswordPropertyTextAttribute` and `EditorAttribute`.
|
||||
- `System.Globalization`: Used for culture-invariant parsing of version strings.
|
||||
|
||||
#### Inferred Usage:
|
||||
- `LoggedInUser` is likely instantiated and managed by authentication/UI logic elsewhere in `DbAPIUI` (e.g., login form).
|
||||
- `ConnectionDetailsEx` is intended for use in UI designers (via `Editor` attributes) and runtime registry queries. Its usage implies a dependency on Windows Forms (`System.Windows.Forms.Design`) for editor support.
|
||||
|
||||
---
|
||||
|
||||
### 5. Gotchas
|
||||
|
||||
- **Hardcoded Default Password**: `DbUserPassword` defaults to `"DTSSealBeachHQ"`. This is insecure for production and suggests legacy or development-only usage. Ensure callers explicitly set this value before use.
|
||||
- **Registry Path Fragility**: `GetSqlServerLocalDbPath()` relies on a specific registry structure (`Installed Versions` subkeys as version strings, `InstanceAPIPath` value). Changes in SQL Server LocalDB installation paths or naming conventions may break this logic.
|
||||
- **No Null Safety in `ToString()`**: `LoggedInUser.ToString()` directly accesses `Details.Item1.DisplayName` and `Details.Item2` without null checks. A null `Details` or its components will cause a `NullReferenceException`.
|
||||
- **Editor Attributes Require Windows Forms**: The `[Editor(...)]` attributes depend on `System.Windows.Forms.Design`, which may not be available in non-Windows Forms contexts (e.g., WPF without WinForms interop).
|
||||
- **Version Parsing Assumption**: `double.TryParse(..., CultureInfo.InvariantCulture)` assumes version strings (e.g., `"15.0"`) are decimal numbers. Non-standard version strings (e.g., `"15.0.1"`) may parse incorrectly or be skipped.
|
||||
|
||||
None identified beyond these.
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Logging/LogManager.cs
|
||||
generated_at: "2026-04-16T03:53:51.082342+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "9f33275e470560a6"
|
||||
---
|
||||
|
||||
# Logging
|
||||
|
||||
## 1. Purpose
|
||||
The `LogManager` class provides a centralized logging mechanism for the `DbAPIUI` application, enabling structured logging to both a dedicated file (`DBAPIUI.log`) and the application’s UI screen log (`Form1.UpdateScreenLog`). It uses .NET’s `TraceSource` infrastructure with custom event categories (`LogEvents`) to differentiate log entries by subsystem (e.g., Connections, Sensors), ensuring consistent timestamp formatting and trace output configuration.
|
||||
|
||||
## 2. Public Interface
|
||||
- **`public enum LogEvents`**
|
||||
Defines named log event categories: `Application`, `Message`, `Connections`, `DAS`, `Sensors`, `TestSetups`, `Tags`. Each maps to an `int` value (0–6) used as the trace event ID.
|
||||
|
||||
- **`public static void Log(TraceEventType eventType, LogEvents logEvent, string msg)`**
|
||||
Logs a message to both the `TraceSource` (writing to `DBAPIUI.log`) and the UI screen log via `Form1.UpdateScreenLog`.
|
||||
- `eventType`: Severity level (e.g., `TraceEventType.Error`, `Info`, `Warning`).
|
||||
- `logEvent`: Category from the `LogEvents` enum (used as the trace event ID).
|
||||
- `msg`: The log message string.
|
||||
Internally calls `InitializeSource()` once to configure the `TraceSource`, then emits the trace event and prepends a formatted timestamp (`yyyy-MM-dd HH:mm:ss.fff`) to the message before updating the screen log.
|
||||
|
||||
## 3. Invariants
|
||||
- **Thread-safe initialization**: `InitializeSource()` uses a `lock` on `MyLock` to ensure `MySource` is initialized exactly once, even under concurrent access.
|
||||
- **Non-null `MySource` after first use**: Once `Log()` is called, `MySource` is guaranteed to be non-null for subsequent calls (due to the early-return guard in `InitializeSource()`).
|
||||
- **Trace output format**: All log entries in `DBAPIUI.log` include `DateTime` and `Timestamp` options (via `TraceOutputOptions`), and the listener is indented by 1 level.
|
||||
- **Auto-flush enabled**: `Trace.AutoFlush = true` ensures log data is written immediately after each trace event.
|
||||
- **Log file path**: Hardcoded to `"DBAPIUI.log"` (relative to the application’s working directory).
|
||||
|
||||
## 4. Dependencies
|
||||
- **Dependencies *of* `LogManager`**:
|
||||
- `System.Diagnostics.TraceSource`, `TextWriterTraceListener`, `TraceOptions`, `SourceLevels`, `TraceEventType`.
|
||||
- `System.DateTime`.
|
||||
- `DbAPIUI.Form1` (via `Form1.UpdateScreenLog(string)`—*not imported but referenced directly*).
|
||||
|
||||
- **Dependencies *on* `LogManager`**:
|
||||
- Any part of the `DbAPIUI` application that requires logging (inferred from usage context; not visible in this file).
|
||||
|
||||
## 5. Gotchas
|
||||
- **Hardcoded dependency on `Form1`**: `LogManager` directly calls `Form1.UpdateScreenLog(...)`, implying `Form1` must be instantiated and its `UpdateScreenLog` method must be thread-safe (since `Log()` may be called from non-UI threads). If `Form1` is not yet created or disposed, this could cause a `NullReferenceException`.
|
||||
- **No log rotation or cleanup**: The log file `DBAPIUI.log` grows indefinitely; no mechanism for size limits or archival is present.
|
||||
- **`TraceEventType` enum values used directly as event IDs**: While valid, this conflates severity (`TraceEventType`) with category (`LogEvents`). The event ID passed to `TraceEvent` is `(int)logEvent`, which may conflict with standard `TraceEventType` values if downstream tools expect specific ID ranges.
|
||||
- **No error handling**: If `TextWriterTraceListener` fails (e.g., disk full, permission denied), exceptions are not caught, potentially crashing the caller.
|
||||
- **`DateTime.Now` used twice**: Timestamp is computed once for `UpdateScreenLog`, but `TraceSource` adds its own timestamp via `TraceOutputOptions`. This may cause minor mismatches between UI and file timestamps.
|
||||
- **No way to disable logging**: Once initialized, `MySource.Switch.Level = SourceLevels.All` cannot be changed at runtime.
|
||||
|
||||
None identified beyond these.
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Properties/AssemblyInfo.cs
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Properties/Settings.Designer.cs
|
||||
- DataPRO/DbAPIUI/DbAPIUI/DbAPIUI/Properties/Resources.Designer.cs
|
||||
generated_at: "2026-04-16T03:52:18.591846+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "54a0e0323c40680a"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
## Documentation Page: `DbAPIUI.Properties` Module
|
||||
|
||||
---
|
||||
|
||||
### 1. **Purpose**
|
||||
|
||||
This module provides auto-generated infrastructure for managing application-level settings and resources in the `DbAPIUI` .NET Framework assembly. Specifically, it defines strongly-typed accessors for user-scoped configuration (via `Settings`) and localized string/resource lookup (via `Resources`). It serves as a supporting layer for UI or tooling components that require persistent user preferences (e.g., database folder path) and localized content, but contains no business logic itself.
|
||||
|
||||
---
|
||||
|
||||
### 2. **Public Interface**
|
||||
|
||||
#### `DbAPIUI.Properties.Settings`
|
||||
- **`public static Settings Default { get; }`**
|
||||
Returns the singleton instance of the `Settings` class, synchronized for thread safety. Used to read/write user-scoped settings.
|
||||
|
||||
- **`public string DBFolder { get; set; }`**
|
||||
User-scoped setting for storing a file system path (e.g., to a database folder). Defaults to `""` (empty string). Marked with `[UserScopedSetting]`, meaning it persists per-user and can be modified at runtime.
|
||||
|
||||
#### `DbAPIUI.Properties.Resources`
|
||||
- **`public static ResourceManager ResourceManager { get; }`**
|
||||
Returns the cached `ResourceManager` instance used to retrieve localized resources (e.g., strings, images) by name. Initialized lazily using the assembly-qualified name `"DbAPIUI.Properties.Resources"`.
|
||||
|
||||
- **`public static CultureInfo Culture { get; set; }`**
|
||||
Gets or sets the UI culture used for resource lookups. Allows overriding the current thread’s `CurrentUICulture` for this resource class only.
|
||||
|
||||
> **Note**: No other public types, methods, or properties are exposed in the provided source files.
|
||||
|
||||
---
|
||||
|
||||
### 3. **Invariants**
|
||||
|
||||
- **`Settings.Default` is thread-safe**: The `defaultInstance` is wrapped with `ApplicationSettingsBase.Synchronized()`, ensuring safe concurrent access.
|
||||
- **`DBFolder` is user-scoped**: Values are persisted per-user (not machine-wide), and changes require explicit save (not automatic).
|
||||
- **Resource manager uses assembly-qualified name**: The `Resources` class initializes its `ResourceManager` using `"DbAPIUI.Properties.Resources"` as the base name, implying a corresponding `.resx` file named `Resources.resx` must exist in the `Properties` folder.
|
||||
- **Auto-generated code**: Both `Settings.Designer.cs` and `Resources.Designer.cs` are explicitly marked as auto-generated; manual edits will be overwritten.
|
||||
|
||||
---
|
||||
|
||||
### 4. **Dependencies**
|
||||
|
||||
#### Dependencies *of* this module:
|
||||
- **.NET Framework runtime**: Specifically uses `System.Configuration` (for `ApplicationSettingsBase`), `System.Resources`, and `System.Globalization`.
|
||||
- **Visual Studio tooling**: Generated by `Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator` (v16.10.0.0) and `StronglyTypedResourceBuilder` (v4.0.0.0).
|
||||
- **Underlying `.resx` and `.settings` files**: Though not included in the source, the presence of `Resources.Designer.cs` and `Settings.Designer.cs` implies corresponding `Resources.resx` and `Settings.settings` files exist in the `Properties` folder.
|
||||
|
||||
#### Dependencies *on* this module:
|
||||
- **`DbAPIUI` assembly consumers**: Any UI or service layer referencing `DbAPIUI.Properties.Settings.Default.DBFolder` or localized resources via `DbAPIUI.Properties.Resources`.
|
||||
|
||||
---
|
||||
|
||||
### 5. **Gotchas**
|
||||
|
||||
- **No persistence logic in this module**: The `Settings` class exposes `DBFolder` but provides no `Save()` method in this file. Persistence requires calling `Settings.Default.Save()` from *outside* this module (likely in UI code), or changes will be lost on application exit.
|
||||
- **Empty default `DBFolder`**: The default value is `""`, which may cause runtime errors if callers assume a non-empty path without validation.
|
||||
- **Thread-safety caveat**: While `Synchronized()` ensures thread-safe *access*, it does *not* guarantee atomicity for compound operations (e.g., read-modify-write on `DBFolder`).
|
||||
- **No localization in source**: The `Resources` class is present but contains no actual resource members (e.g., `public static string SomeString { get; }`). This suggests either resources are defined externally (e.g., in `.resx`) or none are currently used.
|
||||
- **Hardcoded GUID/Version**: The assembly GUID and version (`1.0.0.0`) are fixed; changing them requires manual edits to `AssemblyInfo.cs`.
|
||||
|
||||
> **None identified from source alone.**
|
||||
> *(Note: While the above points are inferred from standard .NET behavior and file structure, the source files do not explicitly confirm runtime behavior beyond what is stated in attributes.)*
|
||||
Reference in New Issue
Block a user