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/interface cleanup #6

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,38 @@ public class GenericPageController: Controller
```
This example demonstrates how to asynchronously retrieve the first page content item that matches a given ID, using the fluent API provided by XperienceCommunity.DataContext.

### Using IXperienceDataContext Example:
To demonstrate how to use the IXperienceDataContext interface, consider the following example:


```csharp

public class ContentService
{
private readonly IXperienceDataContext _dataContext;

public ContentService(IXperienceDataContext dataContext)
{
_dataContext = dataContext;
}

public async Task<GenericContent> GetContentItemAsync(Guid contentItemGUID)
{
var contentItemContext = _dataContext.ForContentType<GenericContent>();
return await contentItemContext.FirstOrDefaultAsync(x => x.SystemFields.ContentItemGUID == contentItemGUID);
}

public async Task<GenericPage> GetPageContentAsync(Guid pageGUID)
{
var pageContentContext = _dataContext.ForPageContentType<GenericPage>();
return await pageContentContext.FirstOrDefaultAsync(x => x.SystemFields.PageGUID == pageGUID);
}
}

```
In this example, the ContentService class uses the IXperienceDataContext interface to get contexts for content items and page content. This setup allows you to leverage the fluent API provided by IContentItemContext and IPageContentContext to interact with content items and page content in a type-safe manner.


## Built With

* [Xperience By Kentico](https://www.kentico.com) - Kentico Xperience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal static IEnumerable<object> ExtractFieldValues(this MemberExpression fie
return null;
}

public static IEnumerable<object> ExtractValues(this object? value)
internal static IEnumerable<object> ExtractValues(this object? value)
{
if (value is null)
{
Expand Down
3 changes: 2 additions & 1 deletion src/XperienceCommunity.DataContext/Interfaces/IProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public interface IProcessor
/// Processes the specified content asynchronously.
/// </summary>
/// <param name="content">The content to process.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A task representing the asynchronous operation.</returns>
Task ProcessAsync(T content);
Task ProcessAsync(T content, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the order of the processor.
Expand Down
Loading