Removed ICommandsManager and its usages
This commit is contained in:
parent
83bc55526a
commit
c89cd76396
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
@ -8,10 +8,10 @@ public class DeafultCogwheelConsole : ICogwheelConsole
|
||||
{
|
||||
public string OpeningMessage { get; set; } = "** COGWHEEL CONSOLE **";
|
||||
public bool IsRunning { get; set; }
|
||||
public ICommandsManager CommandsManager { get; set; }
|
||||
public CommandsManager CommandsManager { get; set; }
|
||||
|
||||
|
||||
public void Initialize(ICommandsManager commandsManager)
|
||||
public void Initialize(CommandsManager commandsManager)
|
||||
{
|
||||
CommandsManager = commandsManager;
|
||||
CommandsManager.RegisterObject(this);
|
||||
|
@ -3,7 +3,7 @@
|
||||
using Cogwheel;
|
||||
|
||||
ICogwheelConsole cogwheelConsole = new DeafultCogwheelConsole();
|
||||
ICommandsManager commandsManager = new CommandsManager(cogwheelConsole);
|
||||
CommandsManager commandsManager = new CommandsManager(cogwheelConsole);
|
||||
|
||||
COGWHEEL.Initialize(commandsManager, cogwheelConsole);
|
||||
|
||||
|
@ -11,10 +11,10 @@ public static class COGWHEEL
|
||||
* -[ ]
|
||||
*/
|
||||
|
||||
private static ICommandsManager _commandsManager;
|
||||
private static CommandsManager _commandsManager;
|
||||
private static ICogwheelConsole _console;
|
||||
|
||||
public static void Initialize(ICommandsManager commandsManager, ICogwheelConsole console)
|
||||
public static void Initialize(CommandsManager commandsManager, ICogwheelConsole console)
|
||||
{
|
||||
_commandsManager = commandsManager;
|
||||
_console = console;
|
||||
|
@ -6,7 +6,7 @@ using Exception = System.Exception;
|
||||
|
||||
namespace Cogwheel;
|
||||
|
||||
public class CommandsManager : ICommandsManager
|
||||
public class CommandsManager
|
||||
{
|
||||
public ICogwheelConsole CogwheelConsole { get; set; }
|
||||
|
||||
@ -74,7 +74,7 @@ public class CommandsManager : ICommandsManager
|
||||
return ExecuteCommand(CurrentContext, command.Value);
|
||||
}
|
||||
|
||||
CogwheelConsole.LogWarning($"Command '{command.Value.Item1.Name}' is not static and no valid context was provided, searching for first registered context of type '{command.Value.Item1.Method.DeclaringType}'");
|
||||
//CogwheelConsole.LogWarning($"Command '{command.Value.Item1.Name}' is not static and no valid context was provided, searching for first registered context of type '{command.Value.Item1.Method.DeclaringType}'");
|
||||
context = GetFirstValidRegisteredContext(command.Value.Item1.Method.DeclaringType);
|
||||
if (context is null)
|
||||
{
|
||||
|
@ -4,9 +4,9 @@ public interface ICogwheelConsole
|
||||
{
|
||||
public string OpeningMessage { get; set; }
|
||||
public bool IsRunning { get; set; }
|
||||
public ICommandsManager CommandsManager { get; set; }
|
||||
public CommandsManager CommandsManager { get; set; }
|
||||
|
||||
public void Initialize(ICommandsManager commandsManager); // Make sure to pass the CommandsManager instance to the Console
|
||||
public void Initialize(CommandsManager commandsManager); // Make sure to pass the CommandsManager instance to the Console
|
||||
public void Log(string message);
|
||||
public void LogError(string message);
|
||||
public void LogWarning(string message);
|
||||
|
@ -1,33 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Cogwheel;
|
||||
|
||||
public interface ICommandsManager
|
||||
{
|
||||
public ICogwheelConsole CogwheelConsole { get; set; }
|
||||
public string CommandPattern { get; set; }
|
||||
public List<Assembly> Assemblies { get; set; }
|
||||
public Dictionary<string, ICommand> Commands { get; set; }
|
||||
public Dictionary<Type, Func<string, object>> CustomParsers { get; set; }
|
||||
public object? CurrentContext { get; set; }
|
||||
public Guid? CurrentContextGuid { get; set; }
|
||||
public Dictionary<Guid, object> RegisteredObjectInstances { get; set; }
|
||||
public Dictionary<object, Guid> RegisteredObjectGuids { get; set; }
|
||||
|
||||
|
||||
public void RegisterObject(object obj);
|
||||
public (ICommand, List<object>)? GetCommandAndArgsFromString(string input);
|
||||
public bool RunCommand(string input, object? context = null);
|
||||
public string GetCommandUsage(ICommand command);
|
||||
public bool ExecuteCommand(object obj, (ICommand command, List<object> args) command);
|
||||
public bool TryParseParameter(Type parameterType, string parameterString, out object parsedValue);
|
||||
public ICommand? GetCommandByName(string commandName);
|
||||
|
||||
// Context related stuff
|
||||
public bool IsCommandContextValid(ICommand command, object? context = null);
|
||||
public bool SetContext(object context);
|
||||
public bool SetContext(Guid guid);
|
||||
public bool SetContext(string guidString);
|
||||
public object? GetFirstValidRegisteredContext(Type type);
|
||||
public Guid GetGuidFromContext(object? context = null);
|
||||
}
|
Loading…
Reference in New Issue
Block a user