mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-04 00:56:09 +02:00
Code refactoring
This commit is contained in:
@@ -3,11 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32112.339
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperbolicDownloaderCli", "HyperbolicDownloader\HyperbolicDownloaderCli.csproj", "{7BA90CAF-36A1-4D55-9CE2-E498ECC1B62D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperbolicDownloader", "HyperbolicDownloader\HyperbolicDownloader.csproj", "{7BA90CAF-36A1-4D55-9CE2-E498ECC1B62D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperbolicDownloaderGUI", "HyperbolicDownloaderGUI\HyperbolicDownloaderGUI.csproj", "{E1CE6E07-F8A6-447F-837D-9D1943A42E96}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HyperbolicDownloaderApi", "HyperbolicDownloaderApi\HyperbolicDownloaderApi.csproj", "{45ACEEC6-9AE4-4DA5-9A08-E22F1EBA7E22}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperbolicDownloaderApi", "HyperbolicDownloaderApi\HyperbolicDownloaderApi.csproj", "{45ACEEC6-9AE4-4DA5-9A08-E22F1EBA7E22}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CA4F21C6-5B63-46C1-8576-91BB3FAE4FA7}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
@@ -24,10 +22,6 @@ Global
|
||||
{7BA90CAF-36A1-4D55-9CE2-E498ECC1B62D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7BA90CAF-36A1-4D55-9CE2-E498ECC1B62D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7BA90CAF-36A1-4D55-9CE2-E498ECC1B62D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E1CE6E07-F8A6-447F-837D-9D1943A42E96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E1CE6E07-F8A6-447F-837D-9D1943A42E96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E1CE6E07-F8A6-447F-837D-9D1943A42E96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E1CE6E07-F8A6-447F-837D-9D1943A42E96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{45ACEEC6-9AE4-4DA5-9A08-E22F1EBA7E22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{45ACEEC6-9AE4-4DA5-9A08-E22F1EBA7E22}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{45ACEEC6-9AE4-4DA5-9A08-E22F1EBA7E22}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
using HyperbolicDownloaderApi.Commands;
|
||||
using HyperbolicDownloaderApi.FileProcessing;
|
||||
using HyperbolicDownloaderApi.Networking;
|
||||
|
||||
using Stone_Red_Utilities.ConsoleExtentions;
|
||||
|
||||
namespace HyperbolicDownloaderApi;
|
||||
namespace HyperbolicDownloader;
|
||||
|
||||
internal class InputHandler
|
||||
{
|
||||
private readonly HostsManager hostsManager;
|
||||
private readonly Commander commander = new Commander();
|
||||
private bool exit = false;
|
||||
|
||||
@@ -20,10 +20,8 @@ internal class InputHandler
|
||||
DownloadCommands downloadCommands = new DownloadCommands(hostsManager, filesManager);
|
||||
ClientCommands clientCommands = new ClientCommands();
|
||||
|
||||
this.hostsManager = hostsManager;
|
||||
|
||||
commander.Register((_) => Console.Clear(), "clear", "cls");
|
||||
commander.Register(Exit, "exit", "quit");
|
||||
commander.Register((_) => exit = true, "exit", "quit");
|
||||
commander.Register(clientCommands.ShowInfo, "info", "inf");
|
||||
commander.Register(hostCommands.Discover, "discover", "disc");
|
||||
|
||||
@@ -72,10 +70,4 @@ internal class InputHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Exit(string _)
|
||||
{
|
||||
hostsManager.SaveHosts();
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using Stone_Red_Utilities.ConsoleExtentions;
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace HyperbolicDownloaderApi;
|
||||
namespace HyperbolicDownloader;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
@@ -14,7 +14,7 @@ internal static class Program
|
||||
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
Console.CancelKeyPress += Console_CancelKeyPress;
|
||||
Console.CancelKeyPress += (_, _) => Close();
|
||||
Console.CursorVisible = false;
|
||||
|
||||
ApiManager.OnNotificationMessageRecived += ApiManager_OnNotificationMessageRecived;
|
||||
@@ -35,7 +35,7 @@ internal static class Program
|
||||
|
||||
if (args.Length > 0 && File.Exists(args[0]))
|
||||
{
|
||||
Commands.DownloadCommands downloadCommands = new Commands.DownloadCommands(apiManager.HostsManager, apiManager.FilesManager);
|
||||
HyperbolicDownloaderApi.Commands.DownloadCommands downloadCommands = new HyperbolicDownloaderApi.Commands.DownloadCommands(apiManager.HostsManager, apiManager.FilesManager);
|
||||
downloadCommands.GetFileFrom(args[0]);
|
||||
Console.WriteLine("Do you want to continue using this instance? [y/N]");
|
||||
if (char.ToLower(Console.ReadKey().KeyChar) != 'y')
|
||||
@@ -76,7 +76,7 @@ internal static class Program
|
||||
ConsoleExt.WriteLine("Ready", ConsoleColor.Green);
|
||||
|
||||
inputHandler.ReadInput();
|
||||
ApiManager.ClosePorts();
|
||||
Close();
|
||||
}
|
||||
|
||||
private static void ApiManager_OnNotificationMessageRecived(object? sender, NotificationMessageEventArgs e)
|
||||
@@ -90,7 +90,7 @@ internal static class Program
|
||||
}
|
||||
}
|
||||
|
||||
private static void Console_CancelKeyPress(object? sender, ConsoleCancelEventArgs e)
|
||||
private static void Close()
|
||||
{
|
||||
ApiManager.ClosePorts();
|
||||
apiManager.HostsManager.SaveHosts();
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using HyperbolicDownloaderApi.Managment;
|
||||
using HyperbolicDownloaderApi.Networking;
|
||||
|
||||
using System.Net.Sockets;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace HyperbolicDownloaderApi;
|
||||
namespace HyperbolicDownloaderApi.Networking;
|
||||
|
||||
public class HostsManager
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user