mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 04:34:16 +01:00
Make ConsoleManagerPluginScoped internal as it's supposed to be
This commit is contained in:
parent
69d8968dca
commit
22430ce054
1 changed files with 14 additions and 14 deletions
|
|
@ -19,11 +19,11 @@ namespace Dalamud.Console;
|
||||||
#pragma warning disable SA1015
|
#pragma warning disable SA1015
|
||||||
[ResolveVia<IConsole>]
|
[ResolveVia<IConsole>]
|
||||||
#pragma warning restore SA1015
|
#pragma warning restore SA1015
|
||||||
public class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
internal class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
||||||
{
|
{
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly ConsoleManager console = Service<ConsoleManager>.Get();
|
private readonly ConsoleManager console = Service<ConsoleManager>.Get();
|
||||||
|
|
||||||
private readonly List<IConsoleEntry> trackedEntries = new();
|
private readonly List<IConsoleEntry> trackedEntries = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -38,7 +38,7 @@ public class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Prefix { get; private set; }
|
public string Prefix { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
void IInternalDisposableService.DisposeService()
|
void IInternalDisposableService.DisposeService()
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +46,7 @@ public class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
||||||
{
|
{
|
||||||
this.console.RemoveEntry(trackedEntry);
|
this.console.RemoveEntry(trackedEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.trackedEntries.Clear();
|
this.trackedEntries.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,21 +108,21 @@ public class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
||||||
this.console.RemoveEntry(entry);
|
this.console.RemoveEntry(entry);
|
||||||
this.trackedEntries.Remove(entry);
|
this.trackedEntries.Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPrefixedName(string name)
|
private string GetPrefixedName(string name)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(name);
|
ArgumentNullException.ThrowIfNull(name);
|
||||||
|
|
||||||
// If the name is empty, return the prefix to allow for a single command or variable to be top-level.
|
// If the name is empty, return the prefix to allow for a single command or variable to be top-level.
|
||||||
if (name.Length == 0)
|
if (name.Length == 0)
|
||||||
return this.Prefix;
|
return this.Prefix;
|
||||||
|
|
||||||
if (name.Any(char.IsWhiteSpace))
|
if (name.Any(char.IsWhiteSpace))
|
||||||
throw new ArgumentException("Name cannot contain whitespace.", nameof(name));
|
throw new ArgumentException("Name cannot contain whitespace.", nameof(name));
|
||||||
|
|
||||||
return $"{this.Prefix}.{name}";
|
return $"{this.Prefix}.{name}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private IConsoleCommand InternalAddCommand(string name, string description, Delegate func)
|
private IConsoleCommand InternalAddCommand(string name, string description, Delegate func)
|
||||||
{
|
{
|
||||||
var command = this.console.AddCommand(this.GetPrefixedName(name), description, func);
|
var command = this.console.AddCommand(this.GetPrefixedName(name), description, func);
|
||||||
|
|
@ -137,7 +137,7 @@ public class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
||||||
internal static partial class ConsoleManagerPluginUtil
|
internal static partial class ConsoleManagerPluginUtil
|
||||||
{
|
{
|
||||||
private static readonly string[] ReservedNamespaces = ["dalamud", "xl", "plugin"];
|
private static readonly string[] ReservedNamespaces = ["dalamud", "xl", "plugin"];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a sanitized namespace name from a plugin's internal name.
|
/// Get a sanitized namespace name from a plugin's internal name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -147,10 +147,10 @@ internal static partial class ConsoleManagerPluginUtil
|
||||||
{
|
{
|
||||||
// Must be lowercase
|
// Must be lowercase
|
||||||
pluginInternalName = pluginInternalName.ToLowerInvariant();
|
pluginInternalName = pluginInternalName.ToLowerInvariant();
|
||||||
|
|
||||||
// Remove all non-alphabetic characters
|
// Remove all non-alphabetic characters
|
||||||
pluginInternalName = NonAlphaRegex().Replace(pluginInternalName, string.Empty);
|
pluginInternalName = NonAlphaRegex().Replace(pluginInternalName, string.Empty);
|
||||||
|
|
||||||
// Remove reserved namespaces from the start or end
|
// Remove reserved namespaces from the start or end
|
||||||
foreach (var reservedNamespace in ReservedNamespaces)
|
foreach (var reservedNamespace in ReservedNamespaces)
|
||||||
{
|
{
|
||||||
|
|
@ -158,13 +158,13 @@ internal static partial class ConsoleManagerPluginUtil
|
||||||
{
|
{
|
||||||
pluginInternalName = pluginInternalName[reservedNamespace.Length..];
|
pluginInternalName = pluginInternalName[reservedNamespace.Length..];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginInternalName.EndsWith(reservedNamespace))
|
if (pluginInternalName.EndsWith(reservedNamespace))
|
||||||
{
|
{
|
||||||
pluginInternalName = pluginInternalName[..^reservedNamespace.Length];
|
pluginInternalName = pluginInternalName[..^reservedNamespace.Length];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginInternalName;
|
return pluginInternalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue