diff --git a/uSync.BackOffice/SyncHandlers/Handlers/ContentHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/ContentHandler.cs index b698b265..e12efcf8 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/ContentHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/ContentHandler.cs @@ -58,6 +58,7 @@ public ContentHandler( this.serializer = syncItemFactory.GetSerializer("ContentSerializer"); } + /// protected override bool HasChildren(IContent item) => contentService.HasChildren(item.Id); diff --git a/uSync.BackOffice/SyncHandlers/Handlers/MediaHandler.cs b/uSync.BackOffice/SyncHandlers/Handlers/MediaHandler.cs index a4304a3b..49fbd247 100644 --- a/uSync.BackOffice/SyncHandlers/Handlers/MediaHandler.cs +++ b/uSync.BackOffice/SyncHandlers/Handlers/MediaHandler.cs @@ -51,6 +51,7 @@ public MediaHandler( this.mediaService = mediaService; } + /// protected override bool HasChildren(IMedia item) => mediaService.HasChildren(item.Id); diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerBase.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerBase.cs index ff927d5e..c9d8b2e3 100644 --- a/uSync.BackOffice/SyncHandlers/SyncHandlerBase.cs +++ b/uSync.BackOffice/SyncHandlers/SyncHandlerBase.cs @@ -54,6 +54,7 @@ public SyncHandlerBase( this.entityService = entityService; } + /// protected override bool HasChildren(TObject item) => entityService.GetChildren(item.Id).Any(); diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs index 809eae14..6cec4a31 100644 --- a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs +++ b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs @@ -881,6 +881,13 @@ virtual public IEnumerable Export(TObject item, string folder, Hand return uSyncActionHelper.SetAction(attempt, filename, GetItemKey(item), this.Alias).AsEnumerableOfOne(); } + /// + /// does this item have any children ? + /// + /// + /// on items where we can check this (quickly) we can reduce the number of checks we might + /// make on child items or cleaning up where we don't need to. + /// protected virtual bool HasChildren(TObject item) => true; @@ -1783,6 +1790,10 @@ private string GetNameFromFileOrNode(string filename, XElement node) => !string.IsNullOrWhiteSpace(filename) ? filename : node.GetAlias(); + /// + /// get thekey for any caches we might call (thread based cache value) + /// + /// protected string GetCacheKeyBase() => $"keycache_{this.Alias}_{Thread.CurrentThread.ManagedThreadId}"; diff --git a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs index b384f6b3..c85d7160 100644 --- a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs +++ b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs @@ -641,7 +641,12 @@ protected uSyncChange HandleSortOrder(TObject item, int sortOrder) return null; } - protected abstract uSyncChange HandleTrashedState(TObject item, bool trashed, Guid restoreParent); + [Obsolete("Pass in a restore guid for the parent - should relationships be missing")] + protected virtual uSyncChange HandleTrashedState(TObject item, bool trashed) + => uSyncChange.NoChange($"Member/{item.Name}", item.Name); + + protected virtual uSyncChange HandleTrashedState(TObject item, bool trashed, Guid restoreParent) + => uSyncChange.NoChange($"Member/{item.Name}", item.Name); protected string GetExportValue(object value, IPropertyType propertyType, string culture, string segment) {