From 7b34b495afbd986ab07a9688b1587e2c4938ba4b Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Tue, 30 Mar 2021 09:25:34 +0100 Subject: [PATCH] Implement the events now as notifications for DataType Service --- .../Cache/DistributedCacheBinder_Handlers.cs | 18 +++++++----------- .../Cache/DistributedCacheBinderTests.cs | 3 --- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs index 0782579497..a6b0dd73db 100644 --- a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs +++ b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs @@ -33,7 +33,9 @@ namespace Umbraco.Cms.Core.Cache INotificationHandler, INotificationHandler, INotificationHandler, - INotificationHandler + INotificationHandler, + INotificationHandler, + INotificationHandler { private List _unbinders; @@ -64,12 +66,6 @@ namespace Umbraco.Cms.Core.Cache _logger.LogInformation("Initializing Umbraco internal event handlers for cache refreshing."); - // bind to data type events - Bind(() => DataTypeService.Deleted += DataTypeService_Deleted, - () => DataTypeService.Deleted -= DataTypeService_Deleted); - Bind(() => DataTypeService.Saved += DataTypeService_Saved, - () => DataTypeService.Saved -= DataTypeService_Saved); - // bind to stylesheet events Bind(() => FileService.SavedStylesheet += FileService_SavedStylesheet, () => FileService.SavedStylesheet -= FileService_SavedStylesheet); @@ -191,15 +187,15 @@ namespace Umbraco.Cms.Core.Cache #region DataTypeService - private void DataTypeService_Saved(IDataTypeService sender, SaveEventArgs e) + public void Handle(DataTypeSavedNotification notification) { - foreach (var entity in e.SavedEntities) + foreach (var entity in notification.SavedEntities) _distributedCache.RefreshDataTypeCache(entity); } - private void DataTypeService_Deleted(IDataTypeService sender, DeleteEventArgs e) + public void Handle(DataTypeDeletedNotification notification) { - foreach (var entity in e.DeletedEntities) + foreach (var entity in notification.DeletedEntities) _distributedCache.RemoveDataTypeCache(entity); } diff --git a/src/Umbraco.Tests.Integration/Cache/DistributedCacheBinderTests.cs b/src/Umbraco.Tests.Integration/Cache/DistributedCacheBinderTests.cs index 2d9bcf2c9d..80488e91b1 100644 --- a/src/Umbraco.Tests.Integration/Cache/DistributedCacheBinderTests.cs +++ b/src/Umbraco.Tests.Integration/Cache/DistributedCacheBinderTests.cs @@ -42,9 +42,6 @@ namespace Umbraco.Cms.Tests.Integration.Cache var definitions = new IEventDefinition[] { - new EventDefinition>(null, DataTypeService, new SaveEventArgs(Enumerable.Empty())), - new EventDefinition>(null, DataTypeService, new DeleteEventArgs(Enumerable.Empty())), - new EventDefinition>(null, FileService, new SaveEventArgs(Enumerable.Empty())), new EventDefinition>(null, FileService, new DeleteEventArgs(Enumerable.Empty())),