From c46a140d3cb4d8c60d8a60edc7c5dc57ebe406a9 Mon Sep 17 00:00:00 2001 From: Karim Beiranvand Date: Sun, 6 Oct 2024 15:50:54 +0200 Subject: [PATCH] 126 --- .../CommandSwitcher.cs | 33 +++++++++++++++++++ .../Program.cs | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs diff --git a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs new file mode 100644 index 00000000..f1f26264 --- /dev/null +++ b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs @@ -0,0 +1,33 @@ +using notepad_plus_plus_file_management.Interfaces; + +namespace notepad_plus_plus_file_management +{ + public class CommandSwitcher( + ICommandLineArgs commandLineArgs, + IProcessManager processManager + ) : ICommandSwitcher + { + private readonly ICommandLineArgs commandLineArgs = commandLineArgs; + private readonly IProcessManager processManager = processManager; + + public string GetCommand() + { + string command = commandLineArgs.GetByKey("--command"); + return command; + } + + public void Run() + { + if (GetCommand() == "open") + { + processManager.Run(); + } + } + } + + public interface ICommandSwitcher + { + public string GetCommand(); + public void Run(); + } +} \ No newline at end of file diff --git a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs index bd8f8501..08225e08 100644 --- a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs +++ b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs @@ -46,7 +46,7 @@ private static void Main(string[] args) .UseSerilog() .Build(); - var svc = ActivatorUtilities.CreateInstance(host.Services); + var svc = ActivatorUtilities.CreateInstance(host.Services); svc.Run(); }