From 07c96c499452e892b4426f76147ab8d2a34920f0 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Wed, 6 Oct 2021 08:22:50 -0600 Subject: [PATCH] Corrected access modifiers. --- FileLiberator/AudioDecodable.cs | 14 ++++++++----- FileLiberator/Processable.cs | 35 +++++++++++++++++---------------- FileLiberator/Streamable.cs | 24 ++++++++++++---------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/FileLiberator/AudioDecodable.cs b/FileLiberator/AudioDecodable.cs index ae91fc52..24478024 100644 --- a/FileLiberator/AudioDecodable.cs +++ b/FileLiberator/AudioDecodable.cs @@ -11,27 +11,31 @@ namespace FileLiberator public event EventHandler CoverImageDiscovered; public abstract void Cancel(); - public void OnRequestCoverArt(Action setCoverArtDel) + protected void OnRequestCoverArt(Action setCoverArtDel) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(RequestCoverArt) }); RequestCoverArt?.Invoke(this, setCoverArtDel); } - public void OnTitleDiscovered(string title) + + protected void OnTitleDiscovered(string title) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(TitleDiscovered), Title = title }); TitleDiscovered?.Invoke(this, title); } - public void OnAuthorsDiscovered(string authors) + + protected void OnAuthorsDiscovered(string authors) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(AuthorsDiscovered), Authors = authors }); AuthorsDiscovered?.Invoke(this, authors); } - public void OnNarratorsDiscovered(string narrators) + + protected void OnNarratorsDiscovered(string narrators) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(NarratorsDiscovered), Narrators = narrators }); NarratorsDiscovered?.Invoke(this, narrators); } - public void OnCoverImageDiscovered(byte[] coverImage) + + protected void OnCoverImageDiscovered(byte[] coverImage) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(CoverImageDiscovered), CoverImageBytes = coverImage?.Length }); CoverImageDiscovered?.Invoke(this, coverImage); diff --git a/FileLiberator/Processable.cs b/FileLiberator/Processable.cs index dd54df28..9f565d06 100644 --- a/FileLiberator/Processable.cs +++ b/FileLiberator/Processable.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using DataLayer; using Dinah.Core; using Dinah.Core.ErrorHandling; -using Dinah.Core.Net.Http; namespace FileLiberator { @@ -18,14 +17,20 @@ namespace FileLiberator public event EventHandler Completed; + /// True == Valid + public abstract bool Validate(LibraryBook libraryBook); + + /// True == success + public abstract Task ProcessAsync(LibraryBook libraryBook); + // when used in foreach: stateful. deferred execution - public IEnumerable GetValidLibraryBooks(IEnumerable library) + protected IEnumerable GetValidLibraryBooks(IEnumerable library) => library.Where(libraryBook => Validate(libraryBook) && (libraryBook.Book.ContentType != ContentType.Episode || FileManager.Configuration.Instance.DownloadEpisodes) ); - public async Task ProcessSingleAsync(LibraryBook libraryBook, bool validate) + protected async Task ProcessSingleAsync(LibraryBook libraryBook, bool validate) { if (validate && !Validate(libraryBook)) return new StatusHandler { "Validation failed" }; @@ -45,31 +50,27 @@ namespace FileLiberator return status; } - public async Task TryProcessAsync( LibraryBook libraryBook) + protected async Task TryProcessAsync(LibraryBook libraryBook) => Validate(libraryBook) ? await ProcessAsync(libraryBook) : new StatusHandler(); - /// True == Valid - public abstract bool Validate(LibraryBook libraryBook); - - /// True == success - public abstract Task ProcessAsync(LibraryBook libraryBook); - - public void OnBegin(LibraryBook libraryBook) + protected void OnBegin(LibraryBook libraryBook) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Begin), Book = libraryBook.LogFriendly() }); Begin?.Invoke(this, libraryBook); } - public void OnCompleted(LibraryBook libraryBook) - { - Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Completed), Book = libraryBook.LogFriendly() }); - Completed?.Invoke(this, libraryBook); - } - public void OnStatusUpdate(string statusUpdate) + + protected void OnStatusUpdate(string statusUpdate) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StatusUpdate), Status = statusUpdate }); StatusUpdate?.Invoke(this, statusUpdate); } + + protected void OnCompleted(LibraryBook libraryBook) + { + Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Completed), Book = libraryBook.LogFriendly() }); + Completed?.Invoke(this, libraryBook); + } } } diff --git a/FileLiberator/Streamable.cs b/FileLiberator/Streamable.cs index b6dcb5de..6f130e9f 100644 --- a/FileLiberator/Streamable.cs +++ b/FileLiberator/Streamable.cs @@ -9,25 +9,29 @@ namespace FileLiberator public event EventHandler StreamingProgressChanged; public event EventHandler StreamingTimeRemaining; public event EventHandler StreamingCompleted; - public void OnStreamingBegin(string filePath) + + protected void OnStreamingBegin(string filePath) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingBegin), Message = filePath }); StreamingBegin?.Invoke(this, filePath); } - public void OnStreamingCompleted(string filePath) + + protected void OnStreamingProgressChanged(DownloadProgress progress) + { + StreamingProgressChanged?.Invoke(this, progress); + } + + protected void OnStreamingTimeRemaining(TimeSpan timeRemaining) + { + StreamingTimeRemaining?.Invoke(this, timeRemaining); + } + + protected void OnStreamingCompleted(string filePath) { Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingCompleted), Message = filePath }); StreamingCompleted?.Invoke(this, filePath); //TODO: Update file cache } - public void OnStreamingProgressChanged(DownloadProgress progress) - { - StreamingProgressChanged?.Invoke(this, progress); - } - public void OnStreamingTimeRemaining(TimeSpan timeRemaining) - { - StreamingTimeRemaining?.Invoke(this, timeRemaining); - } } }