diff --git a/src/Umbraco.Core/Actions/ActionAssignDomain.cs b/src/Umbraco.Core/Actions/ActionAssignDomain.cs
index 452ca51549d4..b8fd8a46500c 100644
--- a/src/Umbraco.Core/Actions/ActionAssignDomain.cs
+++ b/src/Umbraco.Core/Actions/ActionAssignDomain.cs
@@ -9,26 +9,26 @@ namespace Umbraco.Cms.Core.Actions;
public class ActionAssignDomain : IAction
{
///
- /// The unique action letter
+ /// The unique action letter
///
public const char ActionLetter = 'I';
- ///
+ ///
public char Letter => ActionLetter;
- ///
+ ///
// This is all lower-case because of case sensitive filesystems, see issue: https://github.com/umbraco/Umbraco-CMS/issues/11670
public string Alias => "assigndomain";
- ///
+ ///
public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
- ///
+ ///
public string Icon => "home";
- ///
+ ///
public bool ShowInNotifier => false;
- ///
+ ///
public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionBrowse.cs b/src/Umbraco.Core/Actions/ActionBrowse.cs
index 5be16a01c912..2620888a30e6 100644
--- a/src/Umbraco.Core/Actions/ActionBrowse.cs
+++ b/src/Umbraco.Core/Actions/ActionBrowse.cs
@@ -1,40 +1,41 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is used as a security constraint that grants a user the ability to view nodes in a tree
+/// that has permissions applied to it.
+///
+///
+/// This action should not be invoked. It is used as the minimum required permission to view nodes in the content tree.
+/// By
+/// granting a user this permission, the user is able to see the node in the tree but not edit the document. This may
+/// be used by other trees
+/// that support permissions in the future.
+///
+public class ActionBrowse : IAction
{
///
- /// This action is used as a security constraint that grants a user the ability to view nodes in a tree
- /// that has permissions applied to it.
+ /// The unique action letter
///
- ///
- /// This action should not be invoked. It is used as the minimum required permission to view nodes in the content tree. By
- /// granting a user this permission, the user is able to see the node in the tree but not edit the document. This may be used by other trees
- /// that support permissions in the future.
- ///
- public class ActionBrowse : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'F';
-
- ///
- public char Letter => ActionLetter;
-
- ///
- public bool ShowInNotifier => false;
-
- ///
- public bool CanBePermissionAssigned => true;
-
- ///
- public string Icon => string.Empty;
-
- ///
- public string Alias => "browse";
-
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- }
+ public const char ActionLetter = 'F';
+
+ ///
+ public char Letter => ActionLetter;
+
+ ///
+ public bool ShowInNotifier => false;
+
+ ///
+ public bool CanBePermissionAssigned => true;
+
+ ///
+ public string Icon => string.Empty;
+
+ ///
+ public string Alias => "browse";
+
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
diff --git a/src/Umbraco.Core/Actions/ActionCollection.cs b/src/Umbraco.Core/Actions/ActionCollection.cs
index 1e396952a20a..b204075b8869 100644
--- a/src/Umbraco.Core/Actions/ActionCollection.cs
+++ b/src/Umbraco.Core/Actions/ActionCollection.cs
@@ -1,60 +1,56 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
-using System;
-using System.Collections.Generic;
-using System.Linq;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Extensions;
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// The collection of actions
+///
+public class ActionCollection : BuilderCollectionBase
{
///
- /// The collection of actions
+ /// Initializes a new instance of the class.
///
- public class ActionCollection : BuilderCollectionBase
+ public ActionCollection(Func> items)
+ : base(items)
{
- ///
- /// Initializes a new instance of the class.
- ///
- public ActionCollection(Func> items)
- : base(items)
- {
- }
+ }
- ///
- /// Gets the action of the specified type.
- ///
- /// The specified type to get
- /// The action
- public T? GetAction()
- where T : IAction => this.OfType().FirstOrDefault();
+ ///
+ /// Gets the action of the specified type.
+ ///
+ /// The specified type to get
+ /// The action
+ public T? GetAction()
+ where T : IAction => this.OfType().FirstOrDefault();
- ///
- /// Gets the actions by the specified letters
- ///
- public IEnumerable GetByLetters(IEnumerable letters)
- {
- IAction[] actions = this.ToArray(); // no worry: internally, it's already an array
- return letters
- .Where(x => x.Length == 1)
- .Select(x => actions.FirstOrDefault(y => y.Letter == x[0]))
- .WhereNotNull()
- .ToList();
- }
+ ///
+ /// Gets the actions by the specified letters
+ ///
+ public IEnumerable GetByLetters(IEnumerable letters)
+ {
+ IAction[] actions = this.ToArray(); // no worry: internally, it's already an array
+ return letters
+ .Where(x => x.Length == 1)
+ .Select(x => actions.FirstOrDefault(y => y.Letter == x[0]))
+ .WhereNotNull()
+ .ToList();
+ }
- ///
- /// Gets the actions from an EntityPermission
- ///
- public IReadOnlyList FromEntityPermission(EntityPermission entityPermission)
- {
- IAction[] actions = this.ToArray(); // no worry: internally, it's already an array
- return entityPermission.AssignedPermissions
- .Where(x => x.Length == 1)
- .SelectMany(x => actions.Where(y => y.Letter == x[0]))
- .WhereNotNull()
- .ToList();
- }
+ ///
+ /// Gets the actions from an EntityPermission
+ ///
+ public IReadOnlyList FromEntityPermission(EntityPermission entityPermission)
+ {
+ IAction[] actions = this.ToArray(); // no worry: internally, it's already an array
+ return entityPermission.AssignedPermissions
+ .Where(x => x.Length == 1)
+ .SelectMany(x => actions.Where(y => y.Letter == x[0]))
+ .WhereNotNull()
+ .ToList();
}
}
diff --git a/src/Umbraco.Core/Actions/ActionCollectionBuilder.cs b/src/Umbraco.Core/Actions/ActionCollectionBuilder.cs
index 58e70e4a2aa2..aac1556234e8 100644
--- a/src/Umbraco.Core/Actions/ActionCollectionBuilder.cs
+++ b/src/Umbraco.Core/Actions/ActionCollectionBuilder.cs
@@ -1,35 +1,32 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-using System;
-using System.Collections.Generic;
-using System.Linq;
using Umbraco.Cms.Core.Composing;
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// The action collection builder
+///
+public class ActionCollectionBuilder : LazyCollectionBuilderBase
{
- ///
- /// The action collection builder
- ///
- public class ActionCollectionBuilder : LazyCollectionBuilderBase
+ ///
+ protected override ActionCollectionBuilder This => this;
+
+ ///
+ protected override IEnumerable CreateItems(IServiceProvider factory)
{
- ///
- protected override ActionCollectionBuilder This => this;
+ var items = base.CreateItems(factory).ToList();
- ///
- protected override IEnumerable CreateItems(IServiceProvider factory)
+ // Validate the items, no actions should exist that do not either expose notifications or permissions
+ var invalidItems = items.Where(x => !x.CanBePermissionAssigned && !x.ShowInNotifier).ToList();
+ if (invalidItems.Count == 0)
{
- var items = base.CreateItems(factory).ToList();
-
- // Validate the items, no actions should exist that do not either expose notifications or permissions
- var invalidItems = items.Where(x => !x.CanBePermissionAssigned && !x.ShowInNotifier).ToList();
- if (invalidItems.Count == 0)
- {
- return items;
- }
-
- var invalidActions = string.Join(", ", invalidItems.Select(x => "'" + x.Alias + "'"));
- throw new InvalidOperationException($"Invalid actions {invalidActions}'. All {typeof(IAction)} implementations must be true for either {nameof(IAction.CanBePermissionAssigned)} or {nameof(IAction.ShowInNotifier)}.");
+ return items;
}
+
+ var invalidActions = string.Join(", ", invalidItems.Select(x => "'" + x.Alias + "'"));
+ throw new InvalidOperationException(
+ $"Invalid actions {invalidActions}'. All {typeof(IAction)} implementations must be true for either {nameof(IAction.CanBePermissionAssigned)} or {nameof(IAction.ShowInNotifier)}.");
}
}
diff --git a/src/Umbraco.Core/Actions/ActionCopy.cs b/src/Umbraco.Core/Actions/ActionCopy.cs
index 83a855d1ff0a..02bb17166f17 100644
--- a/src/Umbraco.Core/Actions/ActionCopy.cs
+++ b/src/Umbraco.Core/Actions/ActionCopy.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when copying a document, media, member
+///
+public class ActionCopy : IAction
{
///
- /// This action is invoked when copying a document, media, member
+ /// The unique action letter
///
- public class ActionCopy : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'O';
+ public const char ActionLetter = 'O';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "copy";
+ ///
+ public string Alias => "copy";
- ///
- public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
- ///
- public string Icon => "documents";
+ ///
+ public string Icon => "documents";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs b/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs
index 806868af4023..85490b42f818 100644
--- a/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs
+++ b/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs
@@ -1,29 +1,28 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when creating a blueprint from a content
+///
+public class ActionCreateBlueprintFromContent : IAction
{
- ///
- /// This action is invoked when creating a blueprint from a content
- ///
- public class ActionCreateBlueprintFromContent : IAction
- {
- ///
- public char Letter => 'ï';
+ ///
+ public char Letter => 'ï';
- ///
- public bool ShowInNotifier => false;
+ ///
+ public bool ShowInNotifier => false;
- ///
- public bool CanBePermissionAssigned => true;
+ ///
+ public bool CanBePermissionAssigned => true;
- ///
- public string Icon => "blueprint";
+ ///
+ public string Icon => "blueprint";
- ///
- public string Alias => "createblueprint";
+ ///
+ public string Alias => "createblueprint";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- }
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
diff --git a/src/Umbraco.Core/Actions/ActionDelete.cs b/src/Umbraco.Core/Actions/ActionDelete.cs
index 85c9b39dff29..7d9c4e6a03f8 100644
--- a/src/Umbraco.Core/Actions/ActionDelete.cs
+++ b/src/Umbraco.Core/Actions/ActionDelete.cs
@@ -1,39 +1,38 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when a document, media, member is deleted
+///
+public class ActionDelete : IAction
{
///
- /// This action is invoked when a document, media, member is deleted
+ /// The unique action alias
///
- public class ActionDelete : IAction
- {
- ///
- /// The unique action alias
- ///
- public const string ActionAlias = "delete";
+ public const string ActionAlias = "delete";
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'D';
+ ///
+ /// The unique action letter
+ ///
+ public const char ActionLetter = 'D';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => ActionAlias;
+ ///
+ public string Alias => ActionAlias;
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public string Icon => "delete";
+ ///
+ public string Icon => "delete";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionMove.cs b/src/Umbraco.Core/Actions/ActionMove.cs
index 0f8b4b830550..a40d03d096f9 100644
--- a/src/Umbraco.Core/Actions/ActionMove.cs
+++ b/src/Umbraco.Core/Actions/ActionMove.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked upon creation of a document, media, member
+///
+public class ActionMove : IAction
{
///
- /// This action is invoked upon creation of a document, media, member
+ /// The unique action letter
///
- public class ActionMove : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'M';
+ public const char ActionLetter = 'M';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "move";
+ ///
+ public string Alias => "move";
- ///
- public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
- ///
- public string Icon => "enter";
+ ///
+ public string Icon => "enter";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionNew.cs b/src/Umbraco.Core/Actions/ActionNew.cs
index 25e85cd377c1..31056632ed5c 100644
--- a/src/Umbraco.Core/Actions/ActionNew.cs
+++ b/src/Umbraco.Core/Actions/ActionNew.cs
@@ -1,39 +1,38 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked upon creation of a document
+///
+public class ActionNew : IAction
{
///
- /// This action is invoked upon creation of a document
+ /// The unique action alias
///
- public class ActionNew : IAction
- {
- ///
- /// The unique action alias
- ///
- public const string ActionAlias = "create";
+ public const string ActionAlias = "create";
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'C';
+ ///
+ /// The unique action letter
+ ///
+ public const char ActionLetter = 'C';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => ActionAlias;
+ ///
+ public string Alias => ActionAlias;
- ///
- public string Icon => "add";
+ ///
+ public string Icon => "add";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
+ ///
+ public bool CanBePermissionAssigned => true;
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- }
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
diff --git a/src/Umbraco.Core/Actions/ActionNotify.cs b/src/Umbraco.Core/Actions/ActionNotify.cs
index 3f1e855cff5f..9d1975b852b8 100644
--- a/src/Umbraco.Core/Actions/ActionNotify.cs
+++ b/src/Umbraco.Core/Actions/ActionNotify.cs
@@ -1,29 +1,28 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked upon modifying the notification of a content
+///
+public class ActionNotify : IAction
{
- ///
- /// This action is invoked upon modifying the notification of a content
- ///
- public class ActionNotify : IAction
- {
- ///
- public char Letter => 'N';
+ ///
+ public char Letter => 'N';
- ///
- public bool ShowInNotifier => false;
+ ///
+ public bool ShowInNotifier => false;
- ///
- public bool CanBePermissionAssigned => true;
+ ///
+ public bool CanBePermissionAssigned => true;
- ///
- public string Icon => "megaphone";
+ ///
+ public string Icon => "megaphone";
- ///
- public string Alias => "notify";
+ ///
+ public string Alias => "notify";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- }
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
diff --git a/src/Umbraco.Core/Actions/ActionProtect.cs b/src/Umbraco.Core/Actions/ActionProtect.cs
index 10684a69e2ed..0a5ac8ace8a3 100644
--- a/src/Umbraco.Core/Actions/ActionProtect.cs
+++ b/src/Umbraco.Core/Actions/ActionProtect.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when a document is protected or unprotected
+///
+public class ActionProtect : IAction
{
///
- /// This action is invoked when a document is protected or unprotected
+ /// The unique action letter
///
- public class ActionProtect : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'P';
+ public const char ActionLetter = 'P';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "protect";
+ ///
+ public string Alias => "protect";
- ///
- public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
- ///
- public string Icon => "lock";
+ ///
+ public string Icon => "lock";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionPublish.cs b/src/Umbraco.Core/Actions/ActionPublish.cs
index 02f77d686235..e07b0935bc97 100644
--- a/src/Umbraco.Core/Actions/ActionPublish.cs
+++ b/src/Umbraco.Core/Actions/ActionPublish.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when a document is being published
+///
+public class ActionPublish : IAction
{
///
- /// This action is invoked when a document is being published
+ /// The unique action letter
///
- public class ActionPublish : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'U';
+ public const char ActionLetter = 'U';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "publish";
+ ///
+ public string Alias => "publish";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public string Icon => string.Empty;
+ ///
+ public string Icon => string.Empty;
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionRestore.cs b/src/Umbraco.Core/Actions/ActionRestore.cs
index 164c93e2d5da..79e00f446478 100644
--- a/src/Umbraco.Core/Actions/ActionRestore.cs
+++ b/src/Umbraco.Core/Actions/ActionRestore.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when the content/media item is to be restored from the recycle bin
+///
+public class ActionRestore : IAction
{
///
- /// This action is invoked when the content/media item is to be restored from the recycle bin
+ /// The unique action alias
///
- public class ActionRestore : IAction
- {
- ///
- /// The unique action alias
- ///
- public const string ActionAlias = "restore";
+ public const string ActionAlias = "restore";
- ///
- public char Letter => 'V';
+ ///
+ public char Letter => 'V';
- ///
- public string Alias => ActionAlias;
+ ///
+ public string Alias => ActionAlias;
- ///
- public string? Category => null;
+ ///
+ public string? Category => null;
- ///
- public string Icon => "undo";
+ ///
+ public string Icon => "undo";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => false;
- }
+ ///
+ public bool CanBePermissionAssigned => false;
}
diff --git a/src/Umbraco.Core/Actions/ActionRights.cs b/src/Umbraco.Core/Actions/ActionRights.cs
index fff7cc86525d..08afe7e2db4f 100644
--- a/src/Umbraco.Core/Actions/ActionRights.cs
+++ b/src/Umbraco.Core/Actions/ActionRights.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when rights are changed on a document
+///
+public class ActionRights : IAction
{
///
- /// This action is invoked when rights are changed on a document
+ /// The unique action letter
///
- public class ActionRights : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'R';
+ public const char ActionLetter = 'R';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "rights";
+ ///
+ public string Alias => "rights";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public string Icon => "vcard";
+ ///
+ public string Icon => "vcard";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionRollback.cs b/src/Umbraco.Core/Actions/ActionRollback.cs
index 565a8469c52d..5aada555d3d6 100644
--- a/src/Umbraco.Core/Actions/ActionRollback.cs
+++ b/src/Umbraco.Core/Actions/ActionRollback.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when copying a document is being rolled back
+///
+public class ActionRollback : IAction
{
///
- /// This action is invoked when copying a document is being rolled back
+ /// The unique action letter
///
- public class ActionRollback : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'K';
+ public const char ActionLetter = 'K';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "rollback";
+ ///
+ public string Alias => "rollback";
- ///
- public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
- ///
- public string Icon => "undo";
+ ///
+ public string Icon => "undo";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionSort.cs b/src/Umbraco.Core/Actions/ActionSort.cs
index 1f87bfcc3c5e..b77a44c7307c 100644
--- a/src/Umbraco.Core/Actions/ActionSort.cs
+++ b/src/Umbraco.Core/Actions/ActionSort.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when children to a document, media, member is being sorted
+///
+public class ActionSort : IAction
{
///
- /// This action is invoked when children to a document, media, member is being sorted
+ /// The unique action letter
///
- public class ActionSort : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'S';
+ public const char ActionLetter = 'S';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "sort";
+ ///
+ public string Alias => "sort";
- ///
- public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
- ///
- public string Icon => "navigation-vertical";
+ ///
+ public string Icon => "navigation-vertical";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionToPublish.cs b/src/Umbraco.Core/Actions/ActionToPublish.cs
index 654b71661d6f..bf15ee4e3ba4 100644
--- a/src/Umbraco.Core/Actions/ActionToPublish.cs
+++ b/src/Umbraco.Core/Actions/ActionToPublish.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when children to a document is being sent to published (by an editor without publishrights)
+///
+public class ActionToPublish : IAction
{
///
- /// This action is invoked when children to a document is being sent to published (by an editor without publishrights)
+ /// The unique action letter
///
- public class ActionToPublish : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'H';
+ public const char ActionLetter = 'H';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "sendtopublish";
+ ///
+ public string Alias => "sendtopublish";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public string Icon => "outbox";
+ ///
+ public string Icon => "outbox";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionUnpublish.cs b/src/Umbraco.Core/Actions/ActionUnpublish.cs
index 6e9ec8506b97..c8a83f002e0d 100644
--- a/src/Umbraco.Core/Actions/ActionUnpublish.cs
+++ b/src/Umbraco.Core/Actions/ActionUnpublish.cs
@@ -1,35 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when a document is being unpublished
+///
+public class ActionUnpublish : IAction
{
///
- /// This action is invoked when a document is being unpublished
+ /// The unique action letter
///
- public class ActionUnpublish : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'Z';
-
- ///
- public char Letter => ActionLetter;
+ public const char ActionLetter = 'Z';
- ///
- public string Alias => "unpublish";
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Alias => "unpublish";
- ///
- public string Icon => "circle-dotted";
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public bool ShowInNotifier => false;
+ ///
+ public string Icon => "circle-dotted";
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool ShowInNotifier => false;
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/ActionUpdate.cs b/src/Umbraco.Core/Actions/ActionUpdate.cs
index 3f8092c1fc04..4af2410cc445 100644
--- a/src/Umbraco.Core/Actions/ActionUpdate.cs
+++ b/src/Umbraco.Core/Actions/ActionUpdate.cs
@@ -1,34 +1,33 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// This action is invoked when copying a document or media
+///
+public class ActionUpdate : IAction
{
///
- /// This action is invoked when copying a document or media
+ /// The unique action letter
///
- public class ActionUpdate : IAction
- {
- ///
- /// The unique action letter
- ///
- public const char ActionLetter = 'A';
+ public const char ActionLetter = 'A';
- ///
- public char Letter => ActionLetter;
+ ///
+ public char Letter => ActionLetter;
- ///
- public string Alias => "update";
+ ///
+ public string Alias => "update";
- ///
- public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
+ ///
+ public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
- ///
- public string Icon => "save";
+ ///
+ public string Icon => "save";
- ///
- public bool ShowInNotifier => true;
+ ///
+ public bool ShowInNotifier => true;
- ///
- public bool CanBePermissionAssigned => true;
- }
+ ///
+ public bool CanBePermissionAssigned => true;
}
diff --git a/src/Umbraco.Core/Actions/IAction.cs b/src/Umbraco.Core/Actions/IAction.cs
index 2d9876afc647..f57e697a2e62 100644
--- a/src/Umbraco.Core/Actions/IAction.cs
+++ b/src/Umbraco.Core/Actions/IAction.cs
@@ -1,49 +1,48 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
using Umbraco.Cms.Core.Composing;
-namespace Umbraco.Cms.Core.Actions
+namespace Umbraco.Cms.Core.Actions;
+
+///
+/// Defines a back office action that can be permission assigned or subscribed to for notifications
+///
+///
+/// If an IAction returns false for both ShowInNotifier and CanBePermissionAssigned then the IAction should not exist
+///
+public interface IAction : IDiscoverable
{
///
- /// Defines a back office action that can be permission assigned or subscribed to for notifications
+ /// Gets the letter used to assign a permission (must be unique)
+ ///
+ char Letter { get; }
+
+ ///
+ /// Gets a value indicating whether whether to allow subscribing to notifications for this action
+ ///
+ bool ShowInNotifier { get; }
+
+ ///
+ /// Gets a value indicating whether whether to allow assigning permissions based on this action
+ ///
+ bool CanBePermissionAssigned { get; }
+
+ ///
+ /// Gets the icon to display for this action
+ ///
+ string Icon { get; }
+
+ ///
+ /// Gets the alias for this action (must be unique)
+ ///
+ string Alias { get; }
+
+ ///
+ /// Gets the category used for this action
///
///
- /// If an IAction returns false for both ShowInNotifier and CanBePermissionAssigned then the IAction should not exist
+ /// Used in the UI when assigning permissions
///
- public interface IAction : IDiscoverable
- {
- ///
- /// Gets the letter used to assign a permission (must be unique)
- ///
- char Letter { get; }
-
- ///
- /// Gets a value indicating whether whether to allow subscribing to notifications for this action
- ///
- bool ShowInNotifier { get; }
-
- ///
- /// Gets a value indicating whether whether to allow assigning permissions based on this action
- ///
- bool CanBePermissionAssigned { get; }
-
- ///
- /// Gets the icon to display for this action
- ///
- string Icon { get; }
-
- ///
- /// Gets the alias for this action (must be unique)
- ///
- string Alias { get; }
-
- ///
- /// Gets the category used for this action
- ///
- ///
- /// Used in the UI when assigning permissions
- ///
- string? Category { get; }
- }
+ string? Category { get; }
}
diff --git a/src/Umbraco.Core/Attempt.cs b/src/Umbraco.Core/Attempt.cs
index 71eabd2f0dc3..7a438dece660 100644
--- a/src/Umbraco.Core/Attempt.cs
+++ b/src/Umbraco.Core/Attempt.cs
@@ -1,126 +1,108 @@
-using System;
+namespace Umbraco.Cms.Core;
-namespace Umbraco.Cms.Core
+///
+/// Provides ways to create attempts.
+///
+public static class Attempt
{
+ // note:
+ // cannot rely on overloads only to differentiate between with/without status
+ // in some cases it will always be ambiguous, so be explicit w/ 'WithStatus' methods
+
///
- /// Provides ways to create attempts.
+ /// Creates a successful attempt with a result.
///
- public static class Attempt
- {
- // note:
- // cannot rely on overloads only to differentiate between with/without status
- // in some cases it will always be ambiguous, so be explicit w/ 'WithStatus' methods
-
- ///
- /// Creates a successful attempt with a result.
- ///
- /// The type of the attempted operation result.
- /// The result of the attempt.
- /// The successful attempt.
- public static Attempt Succeed(TResult? result)
- {
- return Attempt.Succeed(result);
- }
-
- ///
- /// Creates a successful attempt with a result and a status.
- ///
- /// The type of the attempted operation result.
- /// The type of the attempted operation status.
- /// The status of the attempt.
- /// The result of the attempt.
- /// The successful attempt.
- public static Attempt SucceedWithStatus(TStatus status, TResult result)
- {
- return Attempt.Succeed(status, result);
- }
+ /// The type of the attempted operation result.
+ /// The result of the attempt.
+ /// The successful attempt.
+ public static Attempt Succeed(TResult? result) => Attempt.Succeed(result);
- ///
- /// Creates a failed attempt.
- ///
- /// The type of the attempted operation result.
- /// The failed attempt.
- public static Attempt Fail()
- {
- return Attempt.Fail();
- }
+ ///
+ /// Creates a successful attempt with a result and a status.
+ ///
+ /// The type of the attempted operation result.
+ /// The type of the attempted operation status.
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The successful attempt.
+ public static Attempt SucceedWithStatus(TStatus status, TResult result) =>
+ Attempt.Succeed(status, result);
- ///
- /// Creates a failed attempt with a result.
- ///
- /// The type of the attempted operation result.
- /// The result of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TResult result)
- {
- return Attempt.Fail(result);
- }
+ ///
+ /// Creates a failed attempt.
+ ///
+ /// The type of the attempted operation result.
+ /// The failed attempt.
+ public static Attempt Fail() => Attempt.Fail();
- ///
- /// Creates a failed attempt with a result and a status.
- ///
- /// The type of the attempted operation result.
- /// The type of the attempted operation status.
- /// The status of the attempt.
- /// The result of the attempt.
- /// The failed attempt.
- public static Attempt FailWithStatus(TStatus status, TResult result)
- {
- return Attempt.Fail(status, result);
- }
+ ///
+ /// Creates a failed attempt with a result.
+ ///
+ /// The type of the attempted operation result.
+ /// The result of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TResult result) => Attempt.Fail(result);
- ///
- /// Creates a failed attempt with a result and an exception.
- ///
- /// The type of the attempted operation result.
- /// The result of the attempt.
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TResult result, Exception exception)
- {
- return Attempt.Fail(result, exception);
- }
+ ///
+ /// Creates a failed attempt with a result and a status.
+ ///
+ /// The type of the attempted operation result.
+ /// The type of the attempted operation status.
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The failed attempt.
+ public static Attempt FailWithStatus(TStatus status, TResult result) =>
+ Attempt.Fail(status, result);
+ ///
+ /// Creates a failed attempt with a result and an exception.
+ ///
+ /// The type of the attempted operation result.
+ /// The result of the attempt.
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TResult result, Exception exception) =>
+ Attempt.Fail(result, exception);
- ///
- /// Creates a failed attempt with a result, an exception and a status.
- ///
- /// The type of the attempted operation result.
- /// The type of the attempted operation status.
- /// The status of the attempt.
- /// The result of the attempt.
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt FailWithStatus(TStatus status, TResult result, Exception exception)
- {
- return Attempt.Fail(status, result, exception);
- }
+ ///
+ /// Creates a failed attempt with a result, an exception and a status.
+ ///
+ /// The type of the attempted operation result.
+ /// The type of the attempted operation status.
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt FailWithStatus(TStatus status, TResult result, Exception exception) => Attempt.Fail(status, result, exception);
- ///
- /// Creates a successful or a failed attempt, with a result.
- ///
- /// The type of the attempted operation result.
- /// A value indicating whether the attempt is successful.
- /// The result of the attempt.
- /// The attempt.
- public static Attempt If(bool condition, TResult result)
- {
- return Attempt.If(condition, result);
- }
+ ///
+ /// Creates a successful or a failed attempt, with a result.
+ ///
+ /// The type of the attempted operation result.
+ /// A value indicating whether the attempt is successful.
+ /// The result of the attempt.
+ /// The attempt.
+ public static Attempt If(bool condition, TResult result) =>
+ Attempt.If(condition, result);
- ///
- /// Creates a successful or a failed attempt, with a result.
- ///
- /// The type of the attempted operation result.
- /// The type of the attempted operation status.
- /// A value indicating whether the attempt is successful.
- /// The status of the successful attempt.
- /// The status of the failed attempt.
- /// The result of the attempt.
- /// The attempt.
- public static Attempt IfWithStatus(bool condition, TStatus succStatus, TStatus failStatus, TResult result)
- {
- return Attempt.If(condition, succStatus, failStatus, result);
- }
- }
+ ///
+ /// Creates a successful or a failed attempt, with a result.
+ ///
+ /// The type of the attempted operation result.
+ /// The type of the attempted operation status.
+ /// A value indicating whether the attempt is successful.
+ /// The status of the successful attempt.
+ /// The status of the failed attempt.
+ /// The result of the attempt.
+ /// The attempt.
+ public static Attempt IfWithStatus(
+ bool condition,
+ TStatus succStatus,
+ TStatus failStatus,
+ TResult result) =>
+ Attempt.If(
+ condition,
+ succStatus,
+ failStatus,
+ result);
}
diff --git a/src/Umbraco.Core/AttemptOfTResult.cs b/src/Umbraco.Core/AttemptOfTResult.cs
index 5cf85964ccc1..2969755d9450 100644
--- a/src/Umbraco.Core/AttemptOfTResult.cs
+++ b/src/Umbraco.Core/AttemptOfTResult.cs
@@ -1,141 +1,111 @@
-using System;
-
-namespace Umbraco.Cms.Core
+namespace Umbraco.Cms.Core;
+
+///
+/// Represents the result of an operation attempt.
+///
+/// The type of the attempted operation result.
+[Serializable]
+public struct Attempt
{
+ // optimize, use a singleton failed attempt
+ private static readonly Attempt Failed = new(false, default, null);
+
+ // private - use Succeed() or Fail() methods to create attempts
+ private Attempt(bool success, TResult? result, Exception? exception)
+ {
+ Success = success;
+ Result = result;
+ Exception = exception;
+ }
+
///
- /// Represents the result of an operation attempt.
+ /// Gets a value indicating whether this was successful.
///
- /// The type of the attempted operation result.
- [Serializable]
- public struct Attempt
- {
- // private - use Succeed() or Fail() methods to create attempts
- private Attempt(bool success, TResult? result, Exception? exception)
- {
- Success = success;
- Result = result;
- Exception = exception;
- }
+ public bool Success { get; }
- ///
- /// Gets a value indicating whether this was successful.
- ///
- public bool Success { get; }
-
- ///
- /// Gets the exception associated with an unsuccessful attempt.
- ///
- public Exception? Exception { get; }
-
- ///
- /// Gets the attempt result.
- ///
- public TResult? Result { get; }
-
- ///
- /// Gets the attempt result, if successful, else a default value.
- ///
- public TResult ResultOr(TResult value)
- {
- if (Success && Result is not null)
- {
- return Result;
- }
+ ///
+ /// Gets the exception associated with an unsuccessful attempt.
+ ///
+ public Exception? Exception { get; }
- return value;
- }
+ ///
+ /// Gets the attempt result.
+ ///
+ public TResult? Result { get; }
- // optimize, use a singleton failed attempt
- private static readonly Attempt Failed = new Attempt(false, default(TResult), null);
+ ///
+ /// Implicitly operator to check if the attempt was successful without having to access the 'success' property
+ ///
+ ///
+ ///
+ public static implicit operator bool(Attempt a) => a.Success;
- ///
- /// Creates a successful attempt.
- ///
- /// The successful attempt.
- public static Attempt Succeed()
+ ///
+ /// Gets the attempt result, if successful, else a default value.
+ ///
+ public TResult ResultOr(TResult value)
+ {
+ if (Success && Result is not null)
{
- return new Attempt(true, default(TResult), null);
+ return Result;
}
- ///
- /// Creates a successful attempt with a result.
- ///
- /// The result of the attempt.
- /// The successful attempt.
- public static Attempt Succeed(TResult? result)
- {
- return new Attempt(true, result, null);
- }
+ return value;
+ }
- ///
- /// Creates a failed attempt.
- ///
- /// The failed attempt.
- public static Attempt Fail()
- {
- return Failed;
- }
+ ///
+ /// Creates a successful attempt.
+ ///
+ /// The successful attempt.
+ public static Attempt Succeed() => new(true, default, null);
- ///
- /// Creates a failed attempt with an exception.
- ///
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt Fail(Exception? exception)
- {
- return new Attempt(false, default(TResult), exception);
- }
+ ///
+ /// Creates a successful attempt with a result.
+ ///
+ /// The result of the attempt.
+ /// The successful attempt.
+ public static Attempt Succeed(TResult? result) => new(true, result, null);
- ///
- /// Creates a failed attempt with a result.
- ///
- /// The result of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TResult result)
- {
- return new Attempt(false, result, null);
- }
+ ///
+ /// Creates a failed attempt.
+ ///
+ /// The failed attempt.
+ public static Attempt Fail() => Failed;
- ///
- /// Creates a failed attempt with a result and an exception.
- ///
- /// The result of the attempt.
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TResult result, Exception exception)
- {
- return new Attempt(false, result, exception);
- }
+ ///
+ /// Creates a failed attempt with an exception.
+ ///
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(Exception? exception) => new(false, default, exception);
- ///
- /// Creates a successful or a failed attempt.
- ///
- /// A value indicating whether the attempt is successful.
- /// The attempt.
- public static Attempt If(bool condition)
- {
- return condition ? new Attempt(true, default(TResult), null) : Failed;
- }
+ ///
+ /// Creates a failed attempt with a result.
+ ///
+ /// The result of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TResult result) => new(false, result, null);
- ///
- /// Creates a successful or a failed attempt, with a result.
- ///
- /// A value indicating whether the attempt is successful.
- /// The result of the attempt.
- /// The attempt.
- public static Attempt If(bool condition, TResult? result)
- {
- return new Attempt(condition, result, null);
- }
+ ///
+ /// Creates a failed attempt with a result and an exception.
+ ///
+ /// The result of the attempt.
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TResult result, Exception exception) => new(false, result, exception);
- ///
- /// Implicitly operator to check if the attempt was successful without having to access the 'success' property
- ///
- ///
- ///
- public static implicit operator bool(Attempt a)
- {
- return a.Success;
- }
- }
+ ///
+ /// Creates a successful or a failed attempt.
+ ///
+ /// A value indicating whether the attempt is successful.
+ /// The attempt.
+ public static Attempt If(bool condition) => condition ? new Attempt(true, default, null) : Failed;
+
+ ///
+ /// Creates a successful or a failed attempt, with a result.
+ ///
+ /// A value indicating whether the attempt is successful.
+ /// The result of the attempt.
+ /// The attempt.
+ public static Attempt If(bool condition, TResult? result) => new(condition, result, null);
}
diff --git a/src/Umbraco.Core/AttemptOfTResultTStatus.cs b/src/Umbraco.Core/AttemptOfTResultTStatus.cs
index 65a3e483344b..e88465b3ad3a 100644
--- a/src/Umbraco.Core/AttemptOfTResultTStatus.cs
+++ b/src/Umbraco.Core/AttemptOfTResultTStatus.cs
@@ -1,142 +1,121 @@
-using System;
+namespace Umbraco.Cms.Core;
-namespace Umbraco.Cms.Core
+///
+/// Represents the result of an operation attempt.
+///
+/// The type of the attempted operation result.
+/// The type of the attempted operation status.
+[Serializable]
+public struct Attempt
{
- ///
- /// Represents the result of an operation attempt.
- ///
- /// The type of the attempted operation result.
- /// The type of the attempted operation status.
- [Serializable]
- public struct Attempt
+ // private - use Succeed() or Fail() methods to create attempts
+ private Attempt(bool success, TResult result, TStatus status, Exception? exception)
{
- ///
- /// Gets a value indicating whether this was successful.
- ///
- public bool Success { get; }
+ Success = success;
+ Result = result;
+ Status = status;
+ Exception = exception;
+ }
- ///
- /// Gets the exception associated with an unsuccessful attempt.
- ///
- public Exception? Exception { get; }
+ ///
+ /// Gets a value indicating whether this was successful.
+ ///
+ public bool Success { get; }
- ///
- /// Gets the attempt result.
- ///
- public TResult Result { get; }
+ ///
+ /// Gets the exception associated with an unsuccessful attempt.
+ ///
+ public Exception? Exception { get; }
- ///
- /// Gets the attempt status.
- ///
- public TStatus Status { get; }
+ ///
+ /// Gets the attempt result.
+ ///
+ public TResult Result { get; }
- // private - use Succeed() or Fail() methods to create attempts
- private Attempt(bool success, TResult result, TStatus status, Exception? exception)
- {
- Success = success;
- Result = result;
- Status = status;
- Exception = exception;
- }
+ ///
+ /// Gets the attempt status.
+ ///
+ public TStatus Status { get; }
- ///
- /// Creates a successful attempt.
- ///
- /// The status of the attempt.
- /// The successful attempt.
- public static Attempt Succeed(TStatus status)
- {
- return new Attempt(true, default(TResult), status, null);
- }
+ ///
+ /// Implicitly operator to check if the attempt was successful without having to access the 'success' property
+ ///
+ ///
+ ///
+ public static implicit operator bool(Attempt a) => a.Success;
- ///
- /// Creates a successful attempt with a result.
- ///
- /// The status of the attempt.
- /// The result of the attempt.
- /// The successful attempt.
- public static Attempt Succeed(TStatus status, TResult result)
- {
- return new Attempt(true, result, status, null);
- }
+ ///
+ /// Creates a successful attempt.
+ ///
+ /// The status of the attempt.
+ /// The successful attempt.
+ public static Attempt Succeed(TStatus status) =>
+ new Attempt(true, default, status, null);
- ///
- /// Creates a failed attempt.
- ///
- /// The status of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TStatus status)
- {
- return new Attempt(false, default(TResult), status, null);
- }
+ ///
+ /// Creates a successful attempt with a result.
+ ///
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The successful attempt.
+ public static Attempt Succeed(TStatus status, TResult result) =>
+ new Attempt(true, result, status, null);
- ///
- /// Creates a failed attempt with an exception.
- ///
- /// The status of the attempt.
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TStatus status, Exception exception)
- {
- return new Attempt(false, default(TResult), status, exception);
- }
+ ///
+ /// Creates a failed attempt.
+ ///
+ /// The status of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TStatus status) =>
+ new Attempt(false, default, status, null);
- ///
- /// Creates a failed attempt with a result.
- ///
- /// The status of the attempt.
- /// The result of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TStatus status, TResult result)
- {
- return new Attempt(false, result, status, null);
- }
+ ///
+ /// Creates a failed attempt with an exception.
+ ///
+ /// The status of the attempt.
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TStatus status, Exception exception) =>
+ new Attempt(false, default, status, exception);
- ///
- /// Creates a failed attempt with a result and an exception.
- ///
- /// The status of the attempt.
- /// The result of the attempt.
- /// The exception causing the failure of the attempt.
- /// The failed attempt.
- public static Attempt Fail(TStatus status, TResult result, Exception exception)
- {
- return new Attempt(false, result, status, exception);
- }
+ ///
+ /// Creates a failed attempt with a result.
+ ///
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TStatus status, TResult result) =>
+ new Attempt(false, result, status, null);
- ///
- /// Creates a successful or a failed attempt.
- ///
- /// A value indicating whether the attempt is successful.
- /// The status of the successful attempt.
- /// The status of the failed attempt.
- /// The attempt.
- public static Attempt If(bool condition, TStatus succStatus, TStatus failStatus)
- {
- return new Attempt(condition, default(TResult), condition ? succStatus : failStatus, null);
- }
+ ///
+ /// Creates a failed attempt with a result and an exception.
+ ///
+ /// The status of the attempt.
+ /// The result of the attempt.
+ /// The exception causing the failure of the attempt.
+ /// The failed attempt.
+ public static Attempt Fail(TStatus status, TResult result, Exception exception) =>
+ new Attempt(false, result, status, exception);
- ///
- /// Creates a successful or a failed attempt, with a result.
- ///
- /// A value indicating whether the attempt is successful.
- /// The status of the successful attempt.
- /// The status of the failed attempt.
- /// The result of the attempt.
- /// The attempt.
- public static Attempt If(bool condition, TStatus succStatus, TStatus failStatus, TResult result)
- {
- return new Attempt(condition, result, condition ? succStatus : failStatus, null);
- }
+ ///
+ /// Creates a successful or a failed attempt.
+ ///
+ /// A value indicating whether the attempt is successful.
+ /// The status of the successful attempt.
+ /// The status of the failed attempt.
+ /// The attempt.
+ public static Attempt If(bool condition, TStatus succStatus, TStatus failStatus) =>
+ new Attempt(condition, default, condition ? succStatus : failStatus, null);
- ///
- /// Implicitly operator to check if the attempt was successful without having to access the 'success' property
- ///
- ///
- ///
- public static implicit operator bool(Attempt a)
- {
- return a.Success;
- }
- }
+ ///
+ /// Creates a successful or a failed attempt, with a result.
+ ///
+ /// A value indicating whether the attempt is successful.
+ /// The status of the successful attempt.
+ /// The status of the failed attempt.
+ /// The result of the attempt.
+ /// The attempt.
+ public static Attempt
+ If(bool condition, TStatus succStatus, TStatus failStatus, TResult result) =>
+ new Attempt(condition, result, condition ? succStatus : failStatus, null);
}
diff --git a/src/Umbraco.Core/Cache/AppCacheExtensions.cs b/src/Umbraco.Core/Cache/AppCacheExtensions.cs
index f5e92cc1166e..0f1f242ed01f 100644
--- a/src/Umbraco.Core/Cache/AppCacheExtensions.cs
+++ b/src/Umbraco.Core/Cache/AppCacheExtensions.cs
@@ -1,66 +1,64 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using Umbraco.Cms.Core.Cache;
-namespace Umbraco.Extensions
+namespace Umbraco.Extensions;
+
+///
+/// Extensions for strongly typed access
+///
+public static class AppCacheExtensions
{
- ///
- /// Extensions for strongly typed access
- ///
- public static class AppCacheExtensions
+ public static T? GetCacheItem(
+ this IAppPolicyCache provider,
+ string cacheKey,
+ Func getCacheItem,
+ TimeSpan? timeout,
+ bool isSliding = false,
+ string[]? dependentFiles = null)
{
- public static T? GetCacheItem(this IAppPolicyCache provider,
- string cacheKey,
- Func getCacheItem,
- TimeSpan? timeout,
- bool isSliding = false,
- string[]? dependentFiles = null)
- {
- var result = provider.Get(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);
- return result == null ? default(T) : result.TryConvertTo().Result;
- }
+ var result = provider.Get(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);
+ return result == null ? default : result.TryConvertTo().Result;
+ }
- public static void InsertCacheItem(this IAppPolicyCache provider,
- string cacheKey,
- Func getCacheItem,
- TimeSpan? timeout = null,
- bool isSliding = false,
- string[]? dependentFiles = null)
- {
- provider.Insert(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);
- }
+ public static void InsertCacheItem(
+ this IAppPolicyCache provider,
+ string cacheKey,
+ Func getCacheItem,
+ TimeSpan? timeout = null,
+ bool isSliding = false,
+ string[]? dependentFiles = null) =>
+ provider.Insert(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);
- public static IEnumerable GetCacheItemsByKeySearch(this IAppCache provider, string keyStartsWith)
- {
- var result = provider.SearchByKey(keyStartsWith);
- return result.Select(x => x.TryConvertTo().Result);
- }
+ public static IEnumerable GetCacheItemsByKeySearch(this IAppCache provider, string keyStartsWith)
+ {
+ IEnumerable