From 44df0dda2b8bfe26bf2dafc5100381d4d141ecf2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 20 Apr 2020 22:45:12 +1000 Subject: [PATCH] adding an event --- .../NuCache/PublishedSnapshotService.cs | 2 ++ .../PublishedSnapshotServiceBase.cs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index a33d9ee427..b6d77dd3a0 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -858,6 +858,8 @@ namespace Umbraco.Web.PublishedCache.NuCache Notify(_contentStore, payloads, RefreshContentTypesLocked); Notify(_mediaStore, payloads, RefreshMediaTypesLocked); + OnNotified(new NotifiedEventArgs(payloads)); + if (_publishedModelFactory.IsLiveFactory()) { //In the case of Pure Live - we actually need to refresh all of the content and the media diff --git a/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs index 20d3e6d8e3..f40b3d10c2 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs @@ -1,11 +1,22 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.PublishedContent; using Umbraco.Web.Cache; namespace Umbraco.Web.PublishedCache { - abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService + internal class NotifiedEventArgs : EventArgs + { + public NotifiedEventArgs(T[] payloads) + { + Payloads = payloads; + } + + public T[] Payloads { get; } + } + + internal abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService { protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor) { @@ -38,5 +49,8 @@ namespace Umbraco.Web.PublishedCache public virtual void Dispose() { } + + protected void OnNotified(NotifiedEventArgs args) => Notified?.Invoke(this, args); + public event EventHandler> Notified; } }