diff --git a/Cogwheel.csproj b/Cogwheel.csproj index 2f4fc77..85b4959 100644 --- a/Cogwheel.csproj +++ b/Cogwheel.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable diff --git a/DeafultCogwheelConsole.cs b/DeafultCogwheelConsole.cs index 04db22b..9d968b3 100644 --- a/DeafultCogwheelConsole.cs +++ b/DeafultCogwheelConsole.cs @@ -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); diff --git a/Program.cs b/Program.cs index cbc250b..04844b9 100644 --- a/Program.cs +++ b/Program.cs @@ -3,7 +3,7 @@ using Cogwheel; ICogwheelConsole cogwheelConsole = new DeafultCogwheelConsole(); -ICommandsManager commandsManager = new CommandsManager(cogwheelConsole); +CommandsManager commandsManager = new CommandsManager(cogwheelConsole); COGWHEEL.Initialize(commandsManager, cogwheelConsole); diff --git a/src/COGWHEEL.cs b/src/COGWHEEL.cs index fbccbc1..340c5cb 100644 --- a/src/COGWHEEL.cs +++ b/src/COGWHEEL.cs @@ -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; diff --git a/src/CommandsManager.cs b/src/CommandsManager.cs index a5045b6..27c291e 100644 --- a/src/CommandsManager.cs +++ b/src/CommandsManager.cs @@ -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) { diff --git a/src/interfaces/ICogwheelConsole.cs b/src/interfaces/ICogwheelConsole.cs index db36628..059d229 100644 --- a/src/interfaces/ICogwheelConsole.cs +++ b/src/interfaces/ICogwheelConsole.cs @@ -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); diff --git a/src/interfaces/ICommandsManager.cs b/src/interfaces/ICommandsManager.cs deleted file mode 100644 index 6241639..0000000 --- a/src/interfaces/ICommandsManager.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; - -namespace Cogwheel; - -public interface ICommandsManager -{ - public ICogwheelConsole CogwheelConsole { get; set; } - public string CommandPattern { get; set; } - public List Assemblies { get; set; } - public Dictionary Commands { get; set; } - public Dictionary> CustomParsers { get; set; } - public object? CurrentContext { get; set; } - public Guid? CurrentContextGuid { get; set; } - public Dictionary RegisteredObjectInstances { get; set; } - public Dictionary RegisteredObjectGuids { get; set; } - - - public void RegisterObject(object obj); - public (ICommand, List)? GetCommandAndArgsFromString(string input); - public bool RunCommand(string input, object? context = null); - public string GetCommandUsage(ICommand command); - public bool ExecuteCommand(object obj, (ICommand command, List 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); -} \ No newline at end of file