From 1462e6c3afadc4c785217a3b616184bbd5fc82d7 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 2 Mar 2021 14:30:57 +0100 Subject: [PATCH] Split notifications into separate classes + move namespace --- .../Events/ICancelableNotification.cs | 10 + .../Compose/NotificationsHandler.cs | 2 +- .../Compose/RelateOnTrashHandler.cs | 2 +- ...ropertyEditorContentNotificationHandler.cs | 2 +- .../FileUploadPropertyEditor.cs | 3 +- .../ImageCropperPropertyEditor.cs | 2 +- .../Routing/RedirectTrackingHandler.cs | 2 +- .../Services/CancelableNotification.cs | 418 ------------------ .../Services/Implement/ContentService.cs | 2 +- .../Services/Implement/MediaService.cs | 2 +- .../CancelableEnumerableObjectNotification.cs | 18 + .../CancelableObjectNotification.cs | 23 + .../ContentNotificationExtensions.cs | 47 ++ .../Notifications/CopiedNotification.cs | 22 + .../Notifications/CopyingNotification.cs | 22 + .../DeletedBlueprintNotification.cs | 21 + .../Notifications/DeletedNotification.cs | 17 + .../DeletedVersionsNotification.cs | 30 ++ .../Notifications/DeletingNotification.cs | 21 + .../DeletingVersionsNotification.cs | 18 + .../EmptiedRecycleBinNotification.cs | 17 + .../EmptyingRecycleBinNotification.cs | 17 + .../EnumerableObjectNotification.cs | 19 + .../Notifications/MovedNotification.cs | 21 + .../MovedToRecycleBinNotification.cs | 21 + .../Notifications/MovingNotification.cs | 21 + .../MovingToRecycleBinNotification.cs | 21 + .../Notifications/ObjectNotification.cs | 20 + .../Notifications/PublishedNotification.cs | 21 + .../Notifications/PublishingNotification.cs | 21 + .../Notifications/RolledBackNotification.cs | 16 + .../Notifications/RollingBackNotification.cs | 16 + .../SavedBlueprintNotification.cs | 16 + .../Notifications/SavedNotification.cs | 21 + .../Notifications/SavingNotification.cs | 21 + .../SendingToPublishNotification.cs | 16 + .../SentToPublishNotification.cs | 16 + .../Notifications/SortedNotification.cs | 17 + .../Notifications/SortingNotification.cs | 17 + .../Notifications/UnpublishedNotification.cs | 21 + .../Notifications/UnpublishingNotification.cs | 21 + .../ContentServiceNotificationTests.cs | 2 +- .../Services/ContentServiceTests.cs | 2 +- .../Services/ContentTypeServiceTests.cs | 2 +- .../Services/MediaTypeServiceTests.cs | 2 +- .../Scoping/ScopedNuCacheTests.cs | 3 +- src/Umbraco.Tests/Scoping/ScopedXmlTests.cs | 4 +- 47 files changed, 660 insertions(+), 436 deletions(-) create mode 100644 src/Umbraco.Core/Events/ICancelableNotification.cs delete mode 100644 src/Umbraco.Infrastructure/Services/CancelableNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/DeletedBlueprintNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/DeletedVersionsNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/DeletingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/DeletingVersionsNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/EmptiedRecycleBinNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/EmptyingRecycleBinNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/MovedToRecycleBinNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/MovingToRecycleBinNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/PublishedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/PublishingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SavedBlueprintNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SendingToPublishNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SentToPublishNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/UnpublishedNotification.cs create mode 100644 src/Umbraco.Infrastructure/Services/Notifications/UnpublishingNotification.cs diff --git a/src/Umbraco.Core/Events/ICancelableNotification.cs b/src/Umbraco.Core/Events/ICancelableNotification.cs new file mode 100644 index 0000000000..df1abc672e --- /dev/null +++ b/src/Umbraco.Core/Events/ICancelableNotification.cs @@ -0,0 +1,10 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +namespace Umbraco.Cms.Core.Events +{ + public interface ICancelableNotification : INotification + { + bool Cancel { get; set; } + } +} diff --git a/src/Umbraco.Infrastructure/Compose/NotificationsHandler.cs b/src/Umbraco.Infrastructure/Compose/NotificationsHandler.cs index cfd7121191..205aece4d1 100644 --- a/src/Umbraco.Infrastructure/Compose/NotificationsHandler.cs +++ b/src/Umbraco.Infrastructure/Compose/NotificationsHandler.cs @@ -16,7 +16,7 @@ using Umbraco.Cms.Core.Models.Entities; using Umbraco.Cms.Core.Models.Membership; using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Compose diff --git a/src/Umbraco.Infrastructure/Compose/RelateOnTrashHandler.cs b/src/Umbraco.Infrastructure/Compose/RelateOnTrashHandler.cs index 216b051c86..e1fcdb3bea 100644 --- a/src/Umbraco.Infrastructure/Compose/RelateOnTrashHandler.cs +++ b/src/Umbraco.Infrastructure/Compose/RelateOnTrashHandler.cs @@ -3,7 +3,7 @@ using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Compose diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ComplexPropertyEditorContentNotificationHandler.cs b/src/Umbraco.Infrastructure/PropertyEditors/ComplexPropertyEditorContentNotificationHandler.cs index 083dce1a96..29d23c1c33 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ComplexPropertyEditorContentNotificationHandler.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ComplexPropertyEditorContentNotificationHandler.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.PropertyEditors diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs index 6ef2be84ce..08308af246 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs @@ -14,7 +14,7 @@ using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Serialization; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.PropertyEditors @@ -126,7 +126,6 @@ namespace Umbraco.Cms.Core.PropertyEditors } } - public void Handle(CopiedNotification notification) { // get the upload field properties with a value diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs index ab1c4d9e67..8c618c73e4 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs @@ -16,7 +16,7 @@ using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Serialization; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.PropertyEditors diff --git a/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs b/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs index c1456af8b3..2ff847d32f 100644 --- a/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs +++ b/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs @@ -8,7 +8,7 @@ using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.PublishedCache; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Routing diff --git a/src/Umbraco.Infrastructure/Services/CancelableNotification.cs b/src/Umbraco.Infrastructure/Services/CancelableNotification.cs deleted file mode 100644 index 4e9ef538b6..0000000000 --- a/src/Umbraco.Infrastructure/Services/CancelableNotification.cs +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright (c) Umbraco. -// See LICENSE for more details. - -using System; -using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -using Umbraco.Cms.Core.Models; - -namespace Umbraco.Cms.Infrastructure.Services -{ - // TODO split this file into several small classes and move to another namespace - - public interface ICancelableNotification : INotification - { - bool Cancel { get; set; } - } - - public abstract class ObjectNotification : INotification where T : class - { - protected ObjectNotification(T target, EventMessages messages) - { - Messages = messages; - Target = target; - } - - public EventMessages Messages { get; } - - protected T Target { get; } - } - - public abstract class EnumerableObjectNotification : ObjectNotification> - { - protected EnumerableObjectNotification(T target, EventMessages messages) : base(new [] {target}, messages) - { - } - - protected EnumerableObjectNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - } - - public abstract class CancelableObjectNotification : ObjectNotification, ICancelableNotification where T : class - { - protected CancelableObjectNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public bool Cancel { get; set; } - - public void CancelOperation(EventMessage cancelationMessage) - { - Cancel = true; - cancelationMessage.IsDefaultEventMessage = true; - Messages.Add(cancelationMessage); - } - } - - public abstract class CancelableEnumerableObjectNotification : CancelableObjectNotification> - { - protected CancelableEnumerableObjectNotification(T target, EventMessages messages) : base(new [] {target}, messages) - { - } - protected CancelableEnumerableObjectNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - } - - public class DeletingNotification : CancelableEnumerableObjectNotification - { - public DeletingNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public DeletingNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable DeletedEntities => Target; - } - - public class DeletedNotification : EnumerableObjectNotification - { - public DeletedNotification(T target, EventMessages messages) : base(target, messages) => MediaFilesToDelete = new List(); - - public IEnumerable DeletedEntities => Target; - - public List MediaFilesToDelete { get; } - } - - public class DeletedBlueprintNotification : EnumerableObjectNotification - { - public DeletedBlueprintNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public DeletedBlueprintNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable DeletedBlueprints => Target; - } - - public class SortingNotification : CancelableEnumerableObjectNotification - { - public SortingNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable SortedEntities => Target; - } - - public class SortedNotification : EnumerableObjectNotification - { - public SortedNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable SortedEntities => Target; - } - - public class SavingNotification : CancelableEnumerableObjectNotification - { - public SavingNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public SavingNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable SavedEntities => Target; - } - - public class SavedNotification : EnumerableObjectNotification - { - public SavedNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public SavedNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable SavedEntities => Target; - } - - public class SavedBlueprintNotification : ObjectNotification where T : class - { - public SavedBlueprintNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public T SavedBlueprint => Target; - } - - public class PublishingNotification : CancelableEnumerableObjectNotification - { - public PublishingNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public PublishingNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable PublishedEntities => Target; - } - - public class PublishedNotification : EnumerableObjectNotification - { - public PublishedNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public PublishedNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable PublishedEntities => Target; - } - - public class MovingNotification : CancelableObjectNotification>> - { - public MovingNotification(MoveEventInfo target, EventMessages messages) : base(new[] {target}, messages) - { - } - - public MovingNotification(IEnumerable> target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable> MoveInfoCollection => Target; - } - - public class MovedNotification : ObjectNotification>> - { - public MovedNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) - { - } - - public MovedNotification(IEnumerable> target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable> MoveInfoCollection => Target; - } - - public class MovingToRecycleBinNotification : CancelableObjectNotification>> - { - public MovingToRecycleBinNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) - { - } - - public MovingToRecycleBinNotification(IEnumerable> target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable> MoveInfoCollection => Target; - } - - public class MovedToRecycleBinNotification : ObjectNotification>> - { - public MovedToRecycleBinNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) - { - } - - public MovedToRecycleBinNotification(IEnumerable> target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable> MoveInfoCollection => Target; - } - - public class CopyingNotification : CancelableObjectNotification where T : class - { - public CopyingNotification(T original, T copy, int parentId, EventMessages messages) : base(original, messages) - { - Copy = copy; - ParentId = parentId; - } - - public T Original => Target; - - public T Copy { get; } - - public int ParentId { get; } - } - - public class CopiedNotification : ObjectNotification where T : class - { - public CopiedNotification(T original, T copy, int parentId, EventMessages messages) : base(original, messages) - { - Copy = copy; - ParentId = parentId; - } - - public T Original => Target; - - public T Copy { get; } - - public int ParentId { get; } - } - - public class RollingBackNotification : CancelableObjectNotification where T : class - { - public RollingBackNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public T Entity => Target; - } - - public class RolledBackNotification : ObjectNotification where T : class - { - public RolledBackNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public T Entity => Target; - } - - public class SendingToPublishNotification : CancelableObjectNotification where T : class - { - public SendingToPublishNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public T Entity => Target; - } - - public class SentToPublishNotification : ObjectNotification where T : class - { - public SentToPublishNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public T Entity => Target; - } - - - public class UnpublishingNotification : CancelableEnumerableObjectNotification - { - public UnpublishingNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public UnpublishingNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable UnpublishedEntities => Target; - } - - public class UnpublishedNotification : EnumerableObjectNotification - { - public UnpublishedNotification(T target, EventMessages messages) : base(target, messages) - { - } - - public UnpublishedNotification(IEnumerable target, EventMessages messages) : base(target, messages) - { - } - - public IEnumerable UnpublishedEntities => Target; - } - - public class EmptiedRecycleBinNotification : INotification where T : class - { - public EmptiedRecycleBinNotification(EventMessages messages) - { - Messages = messages; - } - - public EventMessages Messages { get; } - } - - public class EmptyingRecycleBinNotification : EmptiedRecycleBinNotification, ICancelableNotification where T : class - { - public EmptyingRecycleBinNotification(EventMessages messages) - : base(messages) - { - } - - public bool Cancel { get; set; } - } - - public class DeletedVersionsNotification : INotification where T : class - { - public DeletedVersionsNotification(int id, EventMessages messages, int specificVersion = default, bool deletePriorVersions = false, DateTime dateToRetain = default) - { - Id = id; - Messages = messages; - SpecificVersion = specificVersion; - DeletePriorVersions = deletePriorVersions; - DateToRetain = dateToRetain; - } - - public int Id { get; } - - public EventMessages Messages { get; } - - public int SpecificVersion { get; } - - public bool DeletePriorVersions { get; } - - public DateTime DateToRetain { get; } - } - - public class DeletingVersionsNotification : DeletedVersionsNotification, ICancelableNotification where T : class - { - public DeletingVersionsNotification(int id, EventMessages messages, int specificVersion = default, bool deletePriorVersions = false, DateTime dateToRetain = default) - : base(id, messages, specificVersion, deletePriorVersions, dateToRetain) - { - } - - public bool Cancel { get; set; } - } - - public static class ContentNotificationExtensions - { - /// - /// Determines whether a culture is being saved, during a Saving notification - /// - public static bool IsSavingCulture(this SavingNotification notification, T content, string culture) where T : IContentBase - => content.CultureInfos.TryGetValue(culture, out ContentCultureInfos cultureInfo) && cultureInfo.IsDirty(); - - /// - /// Determines whether a culture has been saved, during a Saved notification - /// - public static bool HasSavedCulture(this SavedNotification notification, T content, string culture) where T : IContentBase - => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UpdatedCulture + culture); - - /// - /// Determines whether a culture is being published, during a Publishing notification - /// - public static bool IsPublishingCulture(this PublishingNotification notification, IContent content, string culture) - => content.PublishCultureInfos.TryGetValue(culture, out ContentCultureInfos cultureInfo) && cultureInfo.IsDirty(); - - /// - /// Determines whether a culture is being unpublished, during a Publishing notification - /// - public static bool IsUnpublishingCulture(this UnpublishingNotification notification, IContent content, string culture) - => content.IsPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture); //bit of a hack since we know that the content implementation tracks changes this way - - /// - /// Determines whether a culture has been published, during a Published notification - /// - public static bool HasPublishedCulture(this PublishedNotification notification, IContent content, string culture) - => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.ChangedCulture + culture); - - /// - /// Determines whether a culture has been unpublished, during a Published notification - /// - public static bool HasUnpublishedCulture(this UnpublishedNotification notification, IContent content, string culture) - => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture); - - } -} diff --git a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs index e8013ac5d9..8928b4972d 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs @@ -13,7 +13,7 @@ using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Services.Changes; using Umbraco.Cms.Core.Strings; using Umbraco.Cms.Infrastructure.Persistence.Querying; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Services.Implement diff --git a/src/Umbraco.Infrastructure/Services/Implement/MediaService.cs b/src/Umbraco.Infrastructure/Services/Implement/MediaService.cs index b7fe23dd7f..4ccf48a690 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/MediaService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/MediaService.cs @@ -13,7 +13,7 @@ using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Services.Changes; using Umbraco.Cms.Core.Strings; using Umbraco.Cms.Infrastructure.Persistence.Querying; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Services.Implement diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs new file mode 100644 index 0000000000..3875967530 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs @@ -0,0 +1,18 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public abstract class CancelableEnumerableObjectNotification : CancelableObjectNotification> + { + protected CancelableEnumerableObjectNotification(T target, EventMessages messages) : base(new [] {target}, messages) + { + } + protected CancelableEnumerableObjectNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs new file mode 100644 index 0000000000..603ee9efbb --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs @@ -0,0 +1,23 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public abstract class CancelableObjectNotification : ObjectNotification, ICancelableNotification where T : class + { + protected CancelableObjectNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public bool Cancel { get; set; } + + public void CancelOperation(EventMessage cancelationMessage) + { + Cancel = true; + cancelationMessage.IsDefaultEventMessage = true; + Messages.Add(cancelationMessage); + } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs b/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs new file mode 100644 index 0000000000..1a05c2f79d --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs @@ -0,0 +1,47 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Models; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public static class ContentNotificationExtensions + { + /// + /// Determines whether a culture is being saved, during a Saving notification + /// + public static bool IsSavingCulture(this SavingNotification notification, T content, string culture) where T : IContentBase + => content.CultureInfos.TryGetValue(culture, out ContentCultureInfos cultureInfo) && cultureInfo.IsDirty(); + + /// + /// Determines whether a culture has been saved, during a Saved notification + /// + public static bool HasSavedCulture(this SavedNotification notification, T content, string culture) where T : IContentBase + => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UpdatedCulture + culture); + + /// + /// Determines whether a culture is being published, during a Publishing notification + /// + public static bool IsPublishingCulture(this PublishingNotification notification, IContent content, string culture) + => content.PublishCultureInfos.TryGetValue(culture, out ContentCultureInfos cultureInfo) && cultureInfo.IsDirty(); + + /// + /// Determines whether a culture is being unpublished, during a Publishing notification + /// + public static bool IsUnpublishingCulture(this UnpublishingNotification notification, IContent content, string culture) + => content.IsPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture); //bit of a hack since we know that the content implementation tracks changes this way + + /// + /// Determines whether a culture has been published, during a Published notification + /// + public static bool HasPublishedCulture(this PublishedNotification notification, IContent content, string culture) + => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.ChangedCulture + culture); + + /// + /// Determines whether a culture has been unpublished, during a Published notification + /// + public static bool HasUnpublishedCulture(this UnpublishedNotification notification, IContent content, string culture) + => content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture); + + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs new file mode 100644 index 0000000000..f89487cbc0 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs @@ -0,0 +1,22 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class CopiedNotification : ObjectNotification where T : class + { + public CopiedNotification(T original, T copy, int parentId, EventMessages messages) : base(original, messages) + { + Copy = copy; + ParentId = parentId; + } + + public T Original => Target; + + public T Copy { get; } + + public int ParentId { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs new file mode 100644 index 0000000000..a62b3ba869 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs @@ -0,0 +1,22 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class CopyingNotification : CancelableObjectNotification where T : class + { + public CopyingNotification(T original, T copy, int parentId, EventMessages messages) : base(original, messages) + { + Copy = copy; + ParentId = parentId; + } + + public T Original => Target; + + public T Copy { get; } + + public int ParentId { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletedBlueprintNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/DeletedBlueprintNotification.cs new file mode 100644 index 0000000000..4a4ad777bf --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/DeletedBlueprintNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class DeletedBlueprintNotification : EnumerableObjectNotification + { + public DeletedBlueprintNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public DeletedBlueprintNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable DeletedBlueprints => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs new file mode 100644 index 0000000000..f6e28f74ed --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs @@ -0,0 +1,17 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class DeletedNotification : EnumerableObjectNotification + { + public DeletedNotification(T target, EventMessages messages) : base(target, messages) => MediaFilesToDelete = new List(); + + public IEnumerable DeletedEntities => Target; + + public List MediaFilesToDelete { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletedVersionsNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/DeletedVersionsNotification.cs new file mode 100644 index 0000000000..3f55abf4b4 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/DeletedVersionsNotification.cs @@ -0,0 +1,30 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class DeletedVersionsNotification : INotification where T : class + { + public DeletedVersionsNotification(int id, EventMessages messages, int specificVersion = default, bool deletePriorVersions = false, DateTime dateToRetain = default) + { + Id = id; + Messages = messages; + SpecificVersion = specificVersion; + DeletePriorVersions = deletePriorVersions; + DateToRetain = dateToRetain; + } + + public int Id { get; } + + public EventMessages Messages { get; } + + public int SpecificVersion { get; } + + public bool DeletePriorVersions { get; } + + public DateTime DateToRetain { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/DeletingNotification.cs new file mode 100644 index 0000000000..b821ac2d30 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/DeletingNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class DeletingNotification : CancelableEnumerableObjectNotification + { + public DeletingNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public DeletingNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable DeletedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletingVersionsNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/DeletingVersionsNotification.cs new file mode 100644 index 0000000000..6a02ad402e --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/DeletingVersionsNotification.cs @@ -0,0 +1,18 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class DeletingVersionsNotification : DeletedVersionsNotification, ICancelableNotification where T : class + { + public DeletingVersionsNotification(int id, EventMessages messages, int specificVersion = default, bool deletePriorVersions = false, DateTime dateToRetain = default) + : base(id, messages, specificVersion, deletePriorVersions, dateToRetain) + { + } + + public bool Cancel { get; set; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/EmptiedRecycleBinNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/EmptiedRecycleBinNotification.cs new file mode 100644 index 0000000000..6f8b36cd12 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/EmptiedRecycleBinNotification.cs @@ -0,0 +1,17 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class EmptiedRecycleBinNotification : INotification where T : class + { + public EmptiedRecycleBinNotification(EventMessages messages) + { + Messages = messages; + } + + public EventMessages Messages { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/EmptyingRecycleBinNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/EmptyingRecycleBinNotification.cs new file mode 100644 index 0000000000..e6b55fc79d --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/EmptyingRecycleBinNotification.cs @@ -0,0 +1,17 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class EmptyingRecycleBinNotification : EmptiedRecycleBinNotification, ICancelableNotification where T : class + { + public EmptyingRecycleBinNotification(EventMessages messages) + : base(messages) + { + } + + public bool Cancel { get; set; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs new file mode 100644 index 0000000000..0201040ecf --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs @@ -0,0 +1,19 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public abstract class EnumerableObjectNotification : ObjectNotification> + { + protected EnumerableObjectNotification(T target, EventMessages messages) : base(new [] {target}, messages) + { + } + + protected EnumerableObjectNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs new file mode 100644 index 0000000000..d0b934a1b5 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class MovedNotification : ObjectNotification>> + { + public MovedNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) + { + } + + public MovedNotification(IEnumerable> target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable> MoveInfoCollection => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovedToRecycleBinNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/MovedToRecycleBinNotification.cs new file mode 100644 index 0000000000..785484152a --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/MovedToRecycleBinNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class MovedToRecycleBinNotification : ObjectNotification>> + { + public MovedToRecycleBinNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) + { + } + + public MovedToRecycleBinNotification(IEnumerable> target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable> MoveInfoCollection => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs new file mode 100644 index 0000000000..e3f567346e --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class MovingNotification : CancelableObjectNotification>> + { + public MovingNotification(MoveEventInfo target, EventMessages messages) : base(new[] {target}, messages) + { + } + + public MovingNotification(IEnumerable> target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable> MoveInfoCollection => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovingToRecycleBinNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/MovingToRecycleBinNotification.cs new file mode 100644 index 0000000000..9984136d74 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/MovingToRecycleBinNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class MovingToRecycleBinNotification : CancelableObjectNotification>> + { + public MovingToRecycleBinNotification(MoveEventInfo target, EventMessages messages) : base(new[] { target }, messages) + { + } + + public MovingToRecycleBinNotification(IEnumerable> target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable> MoveInfoCollection => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs new file mode 100644 index 0000000000..a6b84e875d --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs @@ -0,0 +1,20 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public abstract class ObjectNotification : INotification where T : class + { + protected ObjectNotification(T target, EventMessages messages) + { + Messages = messages; + Target = target; + } + + public EventMessages Messages { get; } + + protected T Target { get; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/PublishedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/PublishedNotification.cs new file mode 100644 index 0000000000..fcb4d5de34 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/PublishedNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class PublishedNotification : EnumerableObjectNotification + { + public PublishedNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public PublishedNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable PublishedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/PublishingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/PublishingNotification.cs new file mode 100644 index 0000000000..60972e441d --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/PublishingNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class PublishingNotification : CancelableEnumerableObjectNotification + { + public PublishingNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public PublishingNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable PublishedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs new file mode 100644 index 0000000000..6960133e0c --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs @@ -0,0 +1,16 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class RolledBackNotification : ObjectNotification where T : class + { + public RolledBackNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public T Entity => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs new file mode 100644 index 0000000000..ec2542d415 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs @@ -0,0 +1,16 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class RollingBackNotification : CancelableObjectNotification where T : class + { + public RollingBackNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public T Entity => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SavedBlueprintNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SavedBlueprintNotification.cs new file mode 100644 index 0000000000..5fde3145bc --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SavedBlueprintNotification.cs @@ -0,0 +1,16 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SavedBlueprintNotification : ObjectNotification where T : class + { + public SavedBlueprintNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public T SavedBlueprint => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs new file mode 100644 index 0000000000..6c1265c878 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SavedNotification : EnumerableObjectNotification + { + public SavedNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public SavedNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable SavedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs new file mode 100644 index 0000000000..3f1869a955 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SavingNotification : CancelableEnumerableObjectNotification + { + public SavingNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public SavingNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable SavedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SendingToPublishNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SendingToPublishNotification.cs new file mode 100644 index 0000000000..4d0b1d8782 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SendingToPublishNotification.cs @@ -0,0 +1,16 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SendingToPublishNotification : CancelableObjectNotification where T : class + { + public SendingToPublishNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public T Entity => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SentToPublishNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SentToPublishNotification.cs new file mode 100644 index 0000000000..d870bbb5db --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SentToPublishNotification.cs @@ -0,0 +1,16 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SentToPublishNotification : ObjectNotification where T : class + { + public SentToPublishNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public T Entity => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs new file mode 100644 index 0000000000..10e3c08e03 --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs @@ -0,0 +1,17 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SortedNotification : EnumerableObjectNotification + { + public SortedNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable SortedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs new file mode 100644 index 0000000000..18430b353b --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs @@ -0,0 +1,17 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class SortingNotification : CancelableEnumerableObjectNotification + { + public SortingNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable SortedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/UnpublishedNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/UnpublishedNotification.cs new file mode 100644 index 0000000000..201d37ddfc --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/UnpublishedNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class UnpublishedNotification : EnumerableObjectNotification + { + public UnpublishedNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public UnpublishedNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable UnpublishedEntities => Target; + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/UnpublishingNotification.cs b/src/Umbraco.Infrastructure/Services/Notifications/UnpublishingNotification.cs new file mode 100644 index 0000000000..ac997fad4a --- /dev/null +++ b/src/Umbraco.Infrastructure/Services/Notifications/UnpublishingNotification.cs @@ -0,0 +1,21 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; +using Umbraco.Cms.Core.Events; + +namespace Umbraco.Cms.Infrastructure.Services.Notifications +{ + public class UnpublishingNotification : CancelableEnumerableObjectNotification + { + public UnpublishingNotification(T target, EventMessages messages) : base(target, messages) + { + } + + public UnpublishingNotification(IEnumerable target, EventMessages messages) : base(target, messages) + { + } + + public IEnumerable UnpublishedEntities => Target; + } +} diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceNotificationTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceNotificationTests.cs index ee82e86671..8a093a0427 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceNotificationTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceNotificationTests.cs @@ -11,7 +11,7 @@ using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement; using Umbraco.Cms.Core.Services.Implement; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Tests.Common.Builders; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Cms.Tests.Integration.Testing; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs index 2321613bdc..612dbb87ae 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceTests.cs @@ -21,7 +21,7 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Services.Implement; using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Tests.Common.Builders; using Umbraco.Cms.Tests.Common.Builders.Extensions; using Umbraco.Cms.Tests.Common.Extensions; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs index c8f3bff84a..66d3c3488a 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceTests.cs @@ -12,7 +12,7 @@ using Umbraco.Cms.Core.Exceptions; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Services.Implement; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Tests.Common.Builders; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Cms.Tests.Integration.Testing; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MediaTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MediaTypeServiceTests.cs index 0d9ce8e5b8..45732beb83 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MediaTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/MediaTypeServiceTests.cs @@ -11,7 +11,7 @@ using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Services.Implement; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Tests.Common.Builders; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Cms.Tests.Integration.Testing; diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs index e35959648d..be6d1f6d86 100644 --- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs @@ -17,13 +17,12 @@ using Umbraco.Cms.Core.Persistence.Repositories; using Umbraco.Cms.Core.PublishedCache; using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Core.Services.Implement; using Umbraco.Cms.Core.Strings; using Umbraco.Cms.Core.Sync; using Umbraco.Cms.Core.Web; using Umbraco.Cms.Infrastructure.PublishedCache; using Umbraco.Cms.Infrastructure.PublishedCache.Persistence; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Tests.Common; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Extensions; diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs index 50f4828efd..5731c71930 100644 --- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs @@ -11,11 +11,9 @@ using Umbraco.Cms.Core.DependencyInjection; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.PublishedCache; -using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Core.Services.Implement; using Umbraco.Cms.Core.Sync; using Umbraco.Cms.Core.Web; -using Umbraco.Cms.Infrastructure.Services; +using Umbraco.Cms.Infrastructure.Services.Notifications; using Umbraco.Cms.Infrastructure.Sync; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Extensions;