|
@@ -12,14 +12,14 @@ public static class PrefixedNameUtility
|
|
|
public static string ToPixiEditorRelativePreferenceName(string uniqueName, string name)
|
|
|
{
|
|
|
string[] splitted = name.Split(":");
|
|
|
-
|
|
|
+
|
|
|
string finalName = $"{uniqueName}:{name}";
|
|
|
-
|
|
|
+
|
|
|
if (splitted.Length == 2)
|
|
|
{
|
|
|
finalName = name;
|
|
|
-
|
|
|
- if(splitted[0].Equals("pixieditor", StringComparison.CurrentCultureIgnoreCase))
|
|
|
+
|
|
|
+ if (splitted[0].Equals("pixieditor", StringComparison.CurrentCultureIgnoreCase))
|
|
|
{
|
|
|
finalName = splitted[1];
|
|
|
}
|
|
@@ -42,7 +42,7 @@ public static class PrefixedNameUtility
|
|
|
return preferenceName[(extensionUniqueName.Length + 1)..];
|
|
|
}
|
|
|
|
|
|
- if(preferenceName.Split(":").Length == 1)
|
|
|
+ if (preferenceName.Split(":").Length == 1)
|
|
|
{
|
|
|
return $"pixieditor:{preferenceName}";
|
|
|
}
|
|
@@ -50,13 +50,23 @@ public static class PrefixedNameUtility
|
|
|
return preferenceName;
|
|
|
}
|
|
|
|
|
|
- public static string ToCommandUniqueName(string extensionUniqueName, string metadataUniqueName)
|
|
|
+ public static string ToCommandUniqueName(string extensionUniqueName, string commandUniqueName, bool allowAlreadyPrefixed)
|
|
|
{
|
|
|
- if (metadataUniqueName.StartsWith(extensionUniqueName))
|
|
|
+ if (commandUniqueName.Contains(':'))
|
|
|
+ {
|
|
|
+ if (allowAlreadyPrefixed)
|
|
|
+ {
|
|
|
+ return commandUniqueName;
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new ArgumentException($"Command name '{commandUniqueName}' already contains a prefix. Which is not allowed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (commandUniqueName.StartsWith(extensionUniqueName) || commandUniqueName.StartsWith("PixiEditor."))
|
|
|
{
|
|
|
- return metadataUniqueName;
|
|
|
+ return commandUniqueName;
|
|
|
}
|
|
|
|
|
|
- return $"{extensionUniqueName}:{metadataUniqueName}";
|
|
|
+ return $"{extensionUniqueName}:{commandUniqueName}";
|
|
|
}
|
|
|
}
|