Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/api design #5

Merged
merged 3 commits into from
Jul 22, 2024
Merged

Feature/api design #5

merged 3 commits into from
Jul 22, 2024

Conversation

brandonhenricks
Copy link
Owner

No description provided.

This commit introduces the IXperienceDataContext interface and its concrete implementation, XperienceDataContext, to centralize the data context in the Xperience by Kentico CMS application. It includes methods for accessing content item, page content, and reusable schema contexts. Additionally, the DependencyInjection.cs file has been updated to register IXperienceDataContext as a scoped service, improving the dependency injection setup. Interface adjustments include the introduction of a marker interface, IProcessor, and an update to IProcessor<T> to inherit from it, enhancing the processor type system. Code organization has been improved with new using directives for better readability and maintainability. These changes collectively improve the application's architecture, making it more organized, modular, and extensible.
This commit introduces significant enhancements to the framework's query handling and caching mechanisms. Specifically, it adds a new private field `_parameters` in `ContentItemContext.cs` and `PageContentContext.cs` to dynamically store query parameters. The constructors of these classes have been updated to initialize this field, ensuring it's ready to store query parameters upon object instantiation.

Furthermore, the dynamic handling of query parameters has been improved by populating the `_parameters` collection with parameters extracted from the `QueryParameterManager` using the `GetQueryParameters().ToList()` method. This occurs within a context where expressions are visited to dynamically build up the query parameters.

The cache key generation method `GetCacheKey` in both mentioned contexts has been modified to include the hash code of the `_parameters` collection. This ensures that the cache key is unique based on the specific query parameters, improving the accuracy of cached data retrieval.

In `QueryParameterManager.cs`, enhancements include the introduction of a new private field `_params` to store query parameters, updates to constructors for initializing this field, and the addition of a `GetQueryParameters` method to return the query parameters collection. The `AddParam` method allows adding new key-value pairs to the `_params` collection, and modifications in various condition handling methods ensure that query parameters are appropriately added to this collection. After applying conditions, the `ApplyConditions` method clears the `_params` collection to reset the state for subsequent queries.

These changes collectively improve the framework's ability to construct queries dynamically with varying parameters and enhance cache management by incorporating query-specific details into cache keys.
In both `ContentItemContext.cs` and `PageContentContext.cs` within the `XperienceCommunity.DataContext` namespace, modifications have been made to clear the `_parameters` collection post-fetching results from cache or executing queries asynchronously. This change ensures the reset of any query parameters after each operation, enhancing the reliability and predictability of data fetching operations. Specifically, `_parameters.Clear();` is added after results are obtained from `GetOrCacheAsync` in both contexts, followed by appropriate result handling. This update aims to prevent the unintended reuse of query parameters in subsequent operations.
@brandonhenricks brandonhenricks self-assigned this Jul 22, 2024
@brandonhenricks brandonhenricks added bug Something isn't working enhancement New feature or request labels Jul 22, 2024
@brandonhenricks brandonhenricks merged commit aca0ec4 into master Jul 22, 2024
3 checks passed
@brandonhenricks brandonhenricks deleted the feature/api-design branch July 22, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants