From 5e2833e068413727d3a82ff8e196b7bb25db4eec Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Sun, 24 Dec 2023 13:32:23 +0100 Subject: [PATCH] Overhaul Secrets implementation --- auto-creamapi/Utils/ISecrets.cs | 8 ++++++++ auto-creamapi/Utils/Secrets.EXAMPLE.cs | 14 -------------- auto-creamapi/ViewModels/DownloadViewModel.cs | 10 +++------- 3 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 auto-creamapi/Utils/ISecrets.cs delete mode 100644 auto-creamapi/Utils/Secrets.EXAMPLE.cs diff --git a/auto-creamapi/Utils/ISecrets.cs b/auto-creamapi/Utils/ISecrets.cs new file mode 100644 index 0000000..01840ac --- /dev/null +++ b/auto-creamapi/Utils/ISecrets.cs @@ -0,0 +1,8 @@ +namespace auto_creamapi.Utils +{ + public interface ISecrets + { + public string ForumUsername(); + public string ForumPassword(); + } +} \ No newline at end of file diff --git a/auto-creamapi/Utils/Secrets.EXAMPLE.cs b/auto-creamapi/Utils/Secrets.EXAMPLE.cs deleted file mode 100644 index b25dd40..0000000 --- a/auto-creamapi/Utils/Secrets.EXAMPLE.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace auto_creamapi.Utils -{ - /// - /// To use this: - /// Rename file Secrets.EXAMPLE.cs to Secrets.cs - /// Rename class Secrets_REMOVETHIS to Secrets - /// Enter the relevant info below - /// - public static class Secrets_REMOVETHIS - { - public const string ForumUsername = "Enter username here"; - public const string ForumPassword = "Enter password here"; - } -} \ No newline at end of file diff --git a/auto-creamapi/ViewModels/DownloadViewModel.cs b/auto-creamapi/ViewModels/DownloadViewModel.cs index 2ca63b5..238509c 100644 --- a/auto-creamapi/ViewModels/DownloadViewModel.cs +++ b/auto-creamapi/ViewModels/DownloadViewModel.cs @@ -1,19 +1,16 @@ using System; -using System.Net.Http; using System.Threading.Tasks; using System.Windows; using auto_creamapi.Messenger; using auto_creamapi.Services; using auto_creamapi.Utils; using Microsoft.Extensions.Logging; -using MvvmCross.Logging; using MvvmCross.Navigation; using MvvmCross.Plugin.Messenger; using MvvmCross.ViewModels; namespace auto_creamapi.ViewModels { - public class DownloadViewModel : MvxNavigationViewModel { private readonly IDownloadCreamApiService _download; @@ -25,6 +22,8 @@ namespace auto_creamapi.ViewModels private string _info; private double _progress; + private readonly Secrets _secrets = new(); + public DownloadViewModel(ILoggerFactory loggerFactory, IMvxNavigationService navigationService, IDownloadCreamApiService download, IMvxMessenger messenger) : base(loggerFactory, navigationService) { @@ -80,10 +79,8 @@ namespace auto_creamapi.ViewModels try { await base.Initialize().ConfigureAwait(false); - var download = _download.Download(Secrets.ForumUsername, Secrets.ForumPassword); + var download = _download.Download(_secrets.ForumUsername(), _secrets.ForumPassword()); var filename = await download.ConfigureAwait(false); - /*var extract = _download.Extract(filename); - await extract;*/ var extract = _download.Extract(filename); await extract.ConfigureAwait(false); _token.Dispose(); @@ -102,7 +99,6 @@ namespace auto_creamapi.ViewModels private void OnProgressMessage(ProgressMessage obj) { - //MyLogger.Log.Debug($"{obj.Filename}: {obj.BytesTransferred}"); InfoLabel = obj.Info; FilenameLabel = obj.Filename; Progress = obj.PercentComplete;