From 081878b6f78db19c69a040a7b578516e741adff9 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 12 Aug 2021 18:43:34 -0600 Subject: [PATCH] Remove IStreamProcessable. IProcessible inherits IStreamable. --- FileLiberator/DownloadableBase.cs | 2 +- FileLiberator/IAudioDecodable.cs | 2 +- FileLiberator/IFileLiberator.cs | 4 --- FileLiberator/IProcessable.cs | 2 +- FileLiberator/IStreamProcessable.cs | 5 --- FileLiberator/IStreamable.cs | 2 +- LibationLauncher/LibationLauncher.csproj | 2 +- .../BaseForms/LiberationBaseForm.cs | 31 +++++++++---------- .../ProcessorAutomationController.cs | 18 +++++------ 9 files changed, 28 insertions(+), 40 deletions(-) delete mode 100644 FileLiberator/IFileLiberator.cs delete mode 100644 FileLiberator/IStreamProcessable.cs diff --git a/FileLiberator/DownloadableBase.cs b/FileLiberator/DownloadableBase.cs index 9156e626..38b5a76e 100644 --- a/FileLiberator/DownloadableBase.cs +++ b/FileLiberator/DownloadableBase.cs @@ -6,7 +6,7 @@ using Dinah.Core.Net.Http; namespace FileLiberator { - public abstract class DownloadableBase : IStreamProcessable + public abstract class DownloadableBase : IProcessable { public event EventHandler Begin; public event EventHandler Completed; diff --git a/FileLiberator/IAudioDecodable.cs b/FileLiberator/IAudioDecodable.cs index e1b74e29..128242ef 100644 --- a/FileLiberator/IAudioDecodable.cs +++ b/FileLiberator/IAudioDecodable.cs @@ -2,7 +2,7 @@ namespace FileLiberator { - public interface IAudioDecodable : IStreamProcessable + public interface IAudioDecodable : IProcessable { event EventHandler> RequestCoverArt; event EventHandler TitleDiscovered; diff --git a/FileLiberator/IFileLiberator.cs b/FileLiberator/IFileLiberator.cs deleted file mode 100644 index e6bdf7aa..00000000 --- a/FileLiberator/IFileLiberator.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace FileLiberator -{ - public interface IFileLiberator { } -} diff --git a/FileLiberator/IProcessable.cs b/FileLiberator/IProcessable.cs index 254090b2..6def9301 100644 --- a/FileLiberator/IProcessable.cs +++ b/FileLiberator/IProcessable.cs @@ -5,7 +5,7 @@ using Dinah.Core.ErrorHandling; namespace FileLiberator { - public interface IProcessable : IFileLiberator + public interface IProcessable : IStreamable { event EventHandler Begin; diff --git a/FileLiberator/IStreamProcessable.cs b/FileLiberator/IStreamProcessable.cs deleted file mode 100644 index 360663ab..00000000 --- a/FileLiberator/IStreamProcessable.cs +++ /dev/null @@ -1,5 +0,0 @@ - -namespace FileLiberator -{ - public interface IStreamProcessable : IStreamable, IProcessable { } -} diff --git a/FileLiberator/IStreamable.cs b/FileLiberator/IStreamable.cs index cdc5b1a3..94049a7a 100644 --- a/FileLiberator/IStreamable.cs +++ b/FileLiberator/IStreamable.cs @@ -3,7 +3,7 @@ using Dinah.Core.Net.Http; namespace FileLiberator { - public interface IStreamable : IFileLiberator + public interface IStreamable { event EventHandler StreamingBegin; event EventHandler StreamingProgressChanged; diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index b0816399..41db5551 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 5.4.9.279 + 5.4.9.280 diff --git a/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs b/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs index 2fed2e82..f04788b7 100644 --- a/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs +++ b/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs @@ -11,7 +11,7 @@ namespace LibationWinForms.BookLiberation.BaseForms { public abstract class LiberationBaseForm : Form { - protected IFileLiberator FileLiberator { get; private set; } + protected IStreamable Streamable { get; private set; } protected LogMe LogMe { get; private set; } private int InstanceThreadId { get; } = Thread.CurrentThread.ManagedThreadId; @@ -24,19 +24,19 @@ namespace LibationWinForms.BookLiberation.BaseForms SyncContext = SynchronizationContext.Current; } - public void RegisterFileLiberator(IFileLiberator fileLiberator, LogMe logMe = null) + public void RegisterFileLiberator(IStreamable streamable, LogMe logMe = null) { //IFileLiberator must at least be IStreamable, otherwise the Form won't ever Show() - if (fileLiberator is null || fileLiberator is not IStreamable streamable) return; + if (streamable is null) return; - FileLiberator = fileLiberator; + Streamable = streamable; LogMe = logMe; Subscribe(streamable); - if (FileLiberator is IProcessable processable) + if (Streamable is IProcessable processable) Subscribe(processable); - if (FileLiberator is IAudioDecodable audioDecodable) + if (Streamable is IAudioDecodable audioDecodable) Subscribe(audioDecodable); } @@ -85,21 +85,18 @@ namespace LibationWinForms.BookLiberation.BaseForms } private void UnsubscribeStreamable(object sender, EventArgs e) { - if (FileLiberator is not IStreamable streamable) - return; - FormClosed -= UnsubscribeStreamable; - streamable.StreamingBegin -= OnStreamingBeginShow; - streamable.StreamingBegin -= OnStreamingBegin; - streamable.StreamingProgressChanged -= OnStreamingProgressChanged; - streamable.StreamingTimeRemaining -= OnStreamingTimeRemaining; - streamable.StreamingCompleted -= OnStreamingCompleted; - streamable.StreamingCompleted -= OnStreamingCompletedClose; + Streamable.StreamingBegin -= OnStreamingBeginShow; + Streamable.StreamingBegin -= OnStreamingBegin; + Streamable.StreamingProgressChanged -= OnStreamingProgressChanged; + Streamable.StreamingTimeRemaining -= OnStreamingTimeRemaining; + Streamable.StreamingCompleted -= OnStreamingCompleted; + Streamable.StreamingCompleted -= OnStreamingCompletedClose; } private void UnsubscribeProcessable(object sender, LibraryBook e) { - if (FileLiberator is not IProcessable processable) + if (Streamable is not IProcessable processable) return; processable.Completed -= UnsubscribeProcessable; @@ -110,7 +107,7 @@ namespace LibationWinForms.BookLiberation.BaseForms } private void UnsubscribeAudioDecodable(object sender, EventArgs e) { - if (FileLiberator is not IAudioDecodable audioDecodable) + if (Streamable is not IAudioDecodable audioDecodable) return; Disposed -= UnsubscribeAudioDecodable; diff --git a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs index 126f1321..78faf7e4 100644 --- a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs +++ b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs @@ -79,7 +79,7 @@ namespace LibationWinForms.BookLiberation var automatedBackupsForm = new AutomatedBackupsForm(); var logMe = LogMe.RegisterForm(automatedBackupsForm); - var convertBook = CreateStreamProcessable(logMe); + var convertBook = CreateProcessable(logMe); await new BackupLoop(logMe, convertBook, automatedBackupsForm).RunBackupAsync(); } @@ -91,7 +91,7 @@ namespace LibationWinForms.BookLiberation var automatedBackupsForm = new AutomatedBackupsForm(); var logMe = LogMe.RegisterForm(automatedBackupsForm); - var downloadPdf = CreateStreamProcessable(logMe, completedAction); + var downloadPdf = CreateProcessable(logMe, completedAction); await new BackupLoop(logMe, downloadPdf, automatedBackupsForm).RunBackupAsync(); } @@ -113,7 +113,7 @@ namespace LibationWinForms.BookLiberation private static IProcessable CreateBackupBook(EventHandler completedAction, LogMe logMe) { - var downloadPdf = CreateStreamProcessable(logMe); + var downloadPdf = CreateProcessable(logMe); //Chain pdf download on DownloadDecryptBook.Completed async void onDownloadDecryptBookCompleted(object sender, LibraryBook e) @@ -122,21 +122,21 @@ namespace LibationWinForms.BookLiberation completedAction(sender, e); } - var downloadDecryptBook = CreateStreamProcessable(logMe, onDownloadDecryptBookCompleted); + var downloadDecryptBook = CreateProcessable(logMe, onDownloadDecryptBookCompleted); return downloadDecryptBook; } /// - /// Create a new and links it to a new . + /// Create a new and links it to a new . /// - /// The derrived type to create. + /// The derrived type to create. /// The derrived Form to create on , Show on , Close on , and Dispose on /// The logger /// An additional event handler to handle - /// A new of type - private static TStrProc CreateStreamProcessable(LogMe logMe, EventHandler completedAction = null) + /// A new of type + private static TStrProc CreateProcessable(LogMe logMe, EventHandler completedAction = null) where TForm : LiberationBaseForm, new() - where TStrProc : IStreamProcessable, new() + where TStrProc : IProcessable, new() { var strProc = new TStrProc();