Swapped all System.Root string conversions
to use the `System.RootString` constant. This saves on integer parsing and reduces the number of new strings being created. Since the `System.Root` is `-1`, it didn't need the culture invariant conversion.
This commit is contained in:
@@ -151,7 +151,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
internal static bool HasContentRootAccess(this IUser user, IEntityService entityService)
|
||||
{
|
||||
return ContentPermissionsHelper.HasPathAccess(Constants.System.Root.ToInvariantString(), user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
|
||||
return ContentPermissionsHelper.HasPathAccess(Constants.System.RootString, user.CalculateContentStartNodeIds(entityService), Constants.System.RecycleBinContent);
|
||||
}
|
||||
|
||||
internal static bool HasContentBinAccess(this IUser user, IEntityService entityService)
|
||||
@@ -161,7 +161,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
internal static bool HasMediaRootAccess(this IUser user, IEntityService entityService)
|
||||
{
|
||||
return ContentPermissionsHelper.HasPathAccess(Constants.System.Root.ToInvariantString(), user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
|
||||
return ContentPermissionsHelper.HasPathAccess(Constants.System.RootString, user.CalculateMediaStartNodeIds(entityService), Constants.System.RecycleBinMedia);
|
||||
}
|
||||
|
||||
internal static bool HasMediaBinAccess(this IUser user, IEntityService entityService)
|
||||
@@ -327,7 +327,7 @@ namespace Umbraco.Core.Models
|
||||
? entityService.GetAllPaths(objectType, asn).ToDictionary(x => x.Id, x => x.Path)
|
||||
: new Dictionary<int, string>();
|
||||
|
||||
paths[Constants.System.Root] = Constants.System.Root.ToString(); // entityService does not get that one
|
||||
paths[Constants.System.Root] = Constants.System.RootString; // entityService does not get that one
|
||||
|
||||
var binPath = GetBinPath(objectType);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
// move to parent (or -1), update path, save
|
||||
moving.ParentId = parentId;
|
||||
var movingPath = moving.Path + ","; // save before changing
|
||||
moving.Path = (container == null ? Constants.System.Root.ToString() : container.Path) + "," + moving.Id;
|
||||
moving.Path = (container == null ? Constants.System.RootString : container.Path) + "," + moving.Id;
|
||||
moving.Level = container == null ? 1 : container.Level + 1;
|
||||
Save(moving);
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//null check otherwise we get exceptions
|
||||
if (content.Path.IsNullOrWhiteSpace()) return Enumerable.Empty<IContent>();
|
||||
|
||||
var rootId = Constants.System.Root.ToInvariantString();
|
||||
var rootId = Constants.System.RootString;
|
||||
var ids = content.Path.Split(',')
|
||||
.Where(x => x != rootId && x != content.Id.ToString(CultureInfo.InvariantCulture)).Select(int.Parse).ToArray();
|
||||
if (ids.Any() == false)
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
// if the parentId is root (-1) then we just need an empty string as we are
|
||||
// creating the path below and we don't want -1 in the path
|
||||
if (parentId == Core.Constants.System.Root.ToInvariantString())
|
||||
if (parentId == Core.Constants.System.RootString)
|
||||
{
|
||||
parentId = string.Empty;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace Umbraco.Web.Editors
|
||||
// Make sure that the root virtual path ends with '/'
|
||||
codeFileDisplay.VirtualPath = codeFileDisplay.VirtualPath.EnsureEndsWith("/");
|
||||
|
||||
if (id != Core.Constants.System.Root.ToInvariantString())
|
||||
if (id != Core.Constants.System.RootString)
|
||||
{
|
||||
codeFileDisplay.VirtualPath += id.TrimStart("/").EnsureEndsWith("/");
|
||||
//if it's not new then it will have a path, otherwise it won't
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Web.Models.Trees
|
||||
[DataContract(Name = "node", Namespace = "")]
|
||||
public sealed class TreeRootNode : TreeNode
|
||||
{
|
||||
private static readonly string RootId = Core.Constants.System.Root.ToString(CultureInfo.InvariantCulture);
|
||||
private static readonly string RootId = Core.Constants.System.RootString;
|
||||
private bool _isGroup;
|
||||
private bool _isSingleNodeTree;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Umbraco.Web.Trees
|
||||
//if there are no trees defined for this section but the section is defined then we can have a simple
|
||||
//full screen section without trees
|
||||
var name = Services.TextService.Localize("sections/" + application);
|
||||
return TreeRootNode.CreateSingleTreeRoot(Constants.System.Root.ToInvariantString(), null, null, name, TreeNodeCollection.Empty, true);
|
||||
return TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true);
|
||||
}
|
||||
|
||||
// handle request for a specific tree / or when there is only one tree
|
||||
@@ -114,7 +114,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
// otherwise it's a section with all empty trees, aka a fullscreen section
|
||||
// todo is this true? what if we just failed to TryGetRootNode on all of them? SD: Yes it's true but we should check the result of TryGetRootNode and throw?
|
||||
return TreeRootNode.CreateSingleTreeRoot(Constants.System.Root.ToInvariantString(), null, null, name, TreeNodeCollection.Empty, true);
|
||||
return TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true);
|
||||
}
|
||||
|
||||
// for many groups
|
||||
@@ -180,7 +180,7 @@ namespace Umbraco.Web.Trees
|
||||
var rootNode = await GetRootNode(tree, querystring);
|
||||
|
||||
var sectionRoot = TreeRootNode.CreateSingleTreeRoot(
|
||||
Constants.System.Root.ToInvariantString(),
|
||||
Constants.System.RootString,
|
||||
rootNode.ChildNodesUrl,
|
||||
rootNode.MenuUrl,
|
||||
rootNode.Name,
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Umbraco.Web.Trees
|
||||
var entities = Services.EntityService.GetChildren(Constants.System.Root, UmbracoObjectTypes.DocumentBlueprint).ToArray();
|
||||
|
||||
//check if we're rendering the root in which case we'll render the content types that have blueprints
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//get all blueprint content types
|
||||
var contentTypeAliases = entities.Select(x => ((ContentEntitySlim) x).ContentTypeAlias).Distinct();
|
||||
@@ -91,7 +91,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
// root actions
|
||||
menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
protected override MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
var rootIdString = Constants.System.Root.ToString(CultureInfo.InvariantCulture);
|
||||
var rootIdString = Constants.System.RootString;
|
||||
var hasAccessToRoot = UserStartNodes.Contains(Constants.System.Root);
|
||||
|
||||
var startNodeId = queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)
|
||||
@@ -256,7 +256,7 @@ namespace Umbraco.Web.Trees
|
||||
protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
//check if we're rendering the root
|
||||
if (id == Constants.System.Root.ToInvariantString() && UserStartNodes.Contains(Constants.System.Root))
|
||||
if (id == Constants.System.RootString && UserStartNodes.Contains(Constants.System.Root))
|
||||
{
|
||||
var altStartId = string.Empty;
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Umbraco.Web.Trees
|
||||
altStartId = queryStrings.GetValue<string>(TreeQueryStringParameters.StartNodeId);
|
||||
|
||||
//check if a request has been made to render from a specific start node
|
||||
if (string.IsNullOrEmpty(altStartId) == false && altStartId != "undefined" && altStartId != Constants.System.Root.ToString(CultureInfo.InvariantCulture))
|
||||
if (string.IsNullOrEmpty(altStartId) == false && altStartId != "undefined" && altStartId != Constants.System.RootString)
|
||||
{
|
||||
id = altStartId;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ namespace Umbraco.Web.Trees
|
||||
var nodes = GetTreeNodesInternal(id, queryStrings);
|
||||
|
||||
//only render the recycle bin if we are not in dialog and the start id id still the root
|
||||
if (IsDialog(queryStrings) == false && id == Constants.System.Root.ToInvariantString())
|
||||
if (IsDialog(queryStrings) == false && id == Constants.System.RootString)
|
||||
{
|
||||
nodes.Add(CreateTreeNode(
|
||||
RecycleBinId.ToInvariantString(),
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//set the default to create
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//set the default to create
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
Func<IDictionaryItem, string> ItemSort() => item => item.ItemKey;
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
nodes.AddRange(
|
||||
Services.LocalizationService.GetRootDictionaryItems().OrderBy(ItemSort()).Select(
|
||||
@@ -104,7 +104,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
|
||||
|
||||
if (id != Constants.System.Root.ToInvariantString())
|
||||
if (id != Constants.System.RootString)
|
||||
menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
|
||||
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
var path = string.IsNullOrEmpty(id) == false && id != Constants.System.Root.ToInvariantString()
|
||||
var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString
|
||||
? HttpUtility.UrlDecode(id).TrimStart("/")
|
||||
: "";
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var root = base.CreateRootNode(queryStrings);
|
||||
//check if there are any children
|
||||
root.HasChildren = GetTreeNodes(Constants.System.Root.ToInvariantString(), queryStrings).Any();
|
||||
root.HasChildren = GetTreeNodes(Constants.System.RootString, queryStrings).Any();
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -139,14 +139,14 @@ namespace Umbraco.Web.Trees
|
||||
protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
|
||||
{
|
||||
//if root node no need to visit the filesystem so lets just create the menu and return it
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
return GetMenuForRootNode(queryStrings);
|
||||
}
|
||||
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
var path = string.IsNullOrEmpty(id) == false && id != Constants.System.Root.ToInvariantString()
|
||||
var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString
|
||||
? HttpUtility.UrlDecode(id).TrimStart("/")
|
||||
: "";
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
foreach (var macro in Services.MacroService.GetAll())
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//Create the normal create action
|
||||
menu.Items.Add<ActionNew>(Services.TextService);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Web.Trees
|
||||
//set the default
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
// if the user's start node is not the root then the only menu item to display is refresh
|
||||
if (UserStartNodes.Contains(Constants.System.Root) == false)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
// set the default to create
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
nodes.Add(
|
||||
CreateTreeNode(Constants.Conventions.MemberTypes.AllMembersListId, id, queryStrings, Services.TextService.Localize("member/allMembers"), "icon-users", true,
|
||||
@@ -148,7 +148,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
// root actions
|
||||
if (_provider.IsUmbracoMembershipProvider())
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
// root actions
|
||||
menu.Items.Add(new CreateChildEntity(Services.TextService));
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//Create the normal create action
|
||||
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.ActionAlias));
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
nodes.AddRange(Services.RelationService.GetAllRelationTypes()
|
||||
.Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name,
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var nodes = new TreeNodeCollection();
|
||||
|
||||
var found = id == Constants.System.Root.ToInvariantString()
|
||||
var found = id == Constants.System.RootString
|
||||
? Services.FileService.GetTemplates(-1)
|
||||
: Services.FileService.GetTemplates(int.Parse(id));
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Umbraco.Web.Trees
|
||||
var item = menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
|
||||
item.NavigateToRoute($"{queryStrings.GetRequiredValue<string>("application")}/templates/edit/{id}?create=true");
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
if (id == Constants.System.RootString)
|
||||
{
|
||||
//refresh action
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace Umbraco.Web.Trees
|
||||
/// <returns></returns>
|
||||
protected virtual TreeNode CreateRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var rootNodeAsString = Constants.System.Root.ToString(CultureInfo.InvariantCulture);
|
||||
var rootNodeAsString = Constants.System.RootString;
|
||||
var currApp = queryStrings.GetValue<string>(TreeQueryStringParameters.Application);
|
||||
|
||||
var node = new TreeNode(
|
||||
|
||||
Reference in New Issue
Block a user