Skip to content

Added "Try" Methods and Predicate to Configuration Service#59

Merged
mdwigley merged 1 commit intoenterlucent:mainfrom
mdwigley:issue#58-mdwigley
Sep 3, 2025
Merged

Added "Try" Methods and Predicate to Configuration Service#59
mdwigley merged 1 commit intoenterlucent:mainfrom
mdwigley:issue#58-mdwigley

Conversation

@mdwigley
Copy link
Member

@mdwigley mdwigley commented Sep 3, 2025

Description

This change introduces safe "Try" style registration and unregistration methods to the IConfigService interface and its implementation in ConfigService. The new methods (TryRegisterConfig and TryUnregsterConfig) allow clients to attempt configuration registration and unregistration without exceptions, returning a boolean to indicate success. Additionally, a predicate method IsConfigRegistered was added to check if a configuration type is already registered. The ConfigService class also gained a static helper method, GetInstance, for dependency-injection based construction. Furthermore, base classes for configuration providers were refactored for better separation, and null-handling behavior was improved in FileConfigService to prevent setting null on collection properties.

Related Issue

Motivation and Context

The existing registration and unregistration operations throw exceptions on failure, which can complicate client error handling and reduce API usability. Adding safe "Try" methods simplifies client interaction by providing non-throwing options with clear success feedback. The predicate method enables clients to verify registration state before attempting changes. The DI-friendly static construction helper eases integration into dependency injection pipelines. These additions enhance robustness, clarity, and developer experience across the configuration service.

How Has This Been Tested?

The changes were tested with unit tests covering registration and unregistration both in normal and failure scenarios, ensuring the "Try" methods correctly return success status without throwing exceptions. Predicate checks were validated for correct presence reporting of registered types. The static DI construction was tested by initializing the ConfigService with a service collection in sample applications. Refactored provider base class functionality was verified to maintain existing behavior. Null handling in FileConfigService was tested to confirm collections are not set to null erroneously.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Asset change (adds or updates icons, templates, or other assets)
  • Documentation change (adds or updates documentation)
  • Plugin change (adds or updates a plugin)

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the core logic.
    • I have linked the project issue above.
  • My change requires a change to the assets.
    • I have linked the asset issue above.
  • My change requires a change to the documentation.
    • I have linked the documentation issue above.
  • My change requires a change to a plugin.
    • I have linked the plugin issue above.

@mdwigley mdwigley self-assigned this Sep 3, 2025
@mdwigley mdwigley moved this to In progress in PlugHub Timeline Sep 3, 2025
@mdwigley mdwigley added the approved Change issue has been accepted for implementation label Sep 3, 2025
@mdwigley mdwigley merged commit bcdac96 into enterlucent:main Sep 3, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in PlugHub Timeline Sep 3, 2025
@mdwigley mdwigley deleted the issue#58-mdwigley branch September 3, 2025 08:56
@mdwigley mdwigley changed the title Added Try (Un)Register & Predicate Added "Try" Methods and Predicate to Configuration Service Sep 3, 2025
mdwigley added a commit that referenced this pull request Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Change issue has been accepted for implementation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add "Try" Methods and Predicate to Configuration Service

1 participant