-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor output cache checks for edit/preview mode - Added necessary using directives in `KenticoFeatureExtensions.cs` for new implementations. - Created `XperienceCommunity.OutputCache.Extensions` namespace with `KenticoFeatureExtensions` class, introducing `InPreview` and `InEditMode` methods to extend `HttpContext`. - Removed unused `Kentico.Web.Mvc` and added `XperienceCommunity.OutputCache.Extensions` using directive in `XperienceOutputCachePolicy.cs`. - Refactored `XperienceOutputCachePolicy` to use new extension methods for preview/edit mode checks, enhancing readability. - Fixed formatting in `XperienceCommunity.OutputCache.csproj` for `PackageReference`.
- Loading branch information
1 parent
a55d446
commit 1bf12aa
Showing
3 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/XperienceCommunity.OutputCache/Extensions/KenticoFeatureExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Kentico.Content.Web.Mvc; | ||
using Kentico.PageBuilder.Web.Mvc; | ||
using Kentico.Web.Mvc; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace XperienceCommunity.OutputCache.Extensions | ||
{ | ||
internal static class KenticoFeatureExtensions | ||
{ | ||
/// <summary> | ||
/// Checks if the current request is in preview mode. | ||
/// </summary> | ||
/// <param name="context">The HttpContext object.</param> | ||
/// <returns>True if the request is in preview mode, otherwise false.</returns> | ||
internal static bool InPreview(this HttpContext context) | ||
{ | ||
return context?.Kentico()?.Preview()?.Enabled ?? false; | ||
} | ||
|
||
/// <summary> | ||
/// Checks if the current request is in edit mode. | ||
/// </summary> | ||
/// <param name="context">The HttpContext object.</param> | ||
/// <returns>True if the request is in edit mode, otherwise false.</returns> | ||
internal static bool InEditMode(this HttpContext context) | ||
{ | ||
return context?.Kentico()?.PageBuilder()?.EditMode ?? false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters