Corrected access modifiers.

This commit is contained in:
Michael Bucari-Tovo 2021-10-06 08:22:50 -06:00
parent aa8491f205
commit 07c96c4994
3 changed files with 41 additions and 32 deletions

View File

@ -11,27 +11,31 @@ namespace FileLiberator
public event EventHandler<byte[]> CoverImageDiscovered; public event EventHandler<byte[]> CoverImageDiscovered;
public abstract void Cancel(); public abstract void Cancel();
public void OnRequestCoverArt(Action<byte[]> setCoverArtDel) protected void OnRequestCoverArt(Action<byte[]> setCoverArtDel)
{ {
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(RequestCoverArt) }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(RequestCoverArt) });
RequestCoverArt?.Invoke(this, setCoverArtDel); 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 }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(TitleDiscovered), Title = title });
TitleDiscovered?.Invoke(this, 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 }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(AuthorsDiscovered), Authors = authors });
AuthorsDiscovered?.Invoke(this, 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 }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(NarratorsDiscovered), Narrators = narrators });
NarratorsDiscovered?.Invoke(this, 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 }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(CoverImageDiscovered), CoverImageBytes = coverImage?.Length });
CoverImageDiscovered?.Invoke(this, coverImage); CoverImageDiscovered?.Invoke(this, coverImage);

View File

@ -5,7 +5,6 @@ using System.Threading.Tasks;
using DataLayer; using DataLayer;
using Dinah.Core; using Dinah.Core;
using Dinah.Core.ErrorHandling; using Dinah.Core.ErrorHandling;
using Dinah.Core.Net.Http;
namespace FileLiberator namespace FileLiberator
{ {
@ -18,14 +17,20 @@ namespace FileLiberator
public event EventHandler<LibraryBook> Completed; public event EventHandler<LibraryBook> Completed;
/// <returns>True == Valid</returns>
public abstract bool Validate(LibraryBook libraryBook);
/// <returns>True == success</returns>
public abstract Task<StatusHandler> ProcessAsync(LibraryBook libraryBook);
// when used in foreach: stateful. deferred execution // when used in foreach: stateful. deferred execution
public IEnumerable<LibraryBook> GetValidLibraryBooks(IEnumerable<LibraryBook> library) protected IEnumerable<LibraryBook> GetValidLibraryBooks(IEnumerable<LibraryBook> library)
=> library.Where(libraryBook => => library.Where(libraryBook =>
Validate(libraryBook) Validate(libraryBook)
&& (libraryBook.Book.ContentType != ContentType.Episode || FileManager.Configuration.Instance.DownloadEpisodes) && (libraryBook.Book.ContentType != ContentType.Episode || FileManager.Configuration.Instance.DownloadEpisodes)
); );
public async Task<StatusHandler> ProcessSingleAsync(LibraryBook libraryBook, bool validate) protected async Task<StatusHandler> ProcessSingleAsync(LibraryBook libraryBook, bool validate)
{ {
if (validate && !Validate(libraryBook)) if (validate && !Validate(libraryBook))
return new StatusHandler { "Validation failed" }; return new StatusHandler { "Validation failed" };
@ -45,31 +50,27 @@ namespace FileLiberator
return status; return status;
} }
public async Task<StatusHandler> TryProcessAsync( LibraryBook libraryBook) protected async Task<StatusHandler> TryProcessAsync(LibraryBook libraryBook)
=> Validate(libraryBook) => Validate(libraryBook)
? await ProcessAsync(libraryBook) ? await ProcessAsync(libraryBook)
: new StatusHandler(); : new StatusHandler();
/// <returns>True == Valid</returns> protected void OnBegin(LibraryBook libraryBook)
public abstract bool Validate(LibraryBook libraryBook);
/// <returns>True == success</returns>
public abstract Task<StatusHandler> ProcessAsync(LibraryBook libraryBook);
public void OnBegin(LibraryBook libraryBook)
{ {
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Begin), Book = libraryBook.LogFriendly() }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Begin), Book = libraryBook.LogFriendly() });
Begin?.Invoke(this, libraryBook); Begin?.Invoke(this, libraryBook);
} }
public void OnCompleted(LibraryBook libraryBook)
{ protected void OnStatusUpdate(string statusUpdate)
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Completed), Book = libraryBook.LogFriendly() });
Completed?.Invoke(this, libraryBook);
}
public void OnStatusUpdate(string statusUpdate)
{ {
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StatusUpdate), Status = statusUpdate }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StatusUpdate), Status = statusUpdate });
StatusUpdate?.Invoke(this, 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);
}
} }
} }

View File

@ -9,25 +9,29 @@ namespace FileLiberator
public event EventHandler<DownloadProgress> StreamingProgressChanged; public event EventHandler<DownloadProgress> StreamingProgressChanged;
public event EventHandler<TimeSpan> StreamingTimeRemaining; public event EventHandler<TimeSpan> StreamingTimeRemaining;
public event EventHandler<string> StreamingCompleted; public event EventHandler<string> StreamingCompleted;
public void OnStreamingBegin(string filePath)
protected void OnStreamingBegin(string filePath)
{ {
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingBegin), Message = filePath }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingBegin), Message = filePath });
StreamingBegin?.Invoke(this, 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 }); Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingCompleted), Message = filePath });
StreamingCompleted?.Invoke(this, filePath); StreamingCompleted?.Invoke(this, filePath);
//TODO: Update file cache //TODO: Update file cache
} }
public void OnStreamingProgressChanged(DownloadProgress progress)
{
StreamingProgressChanged?.Invoke(this, progress);
}
public void OnStreamingTimeRemaining(TimeSpan timeRemaining)
{
StreamingTimeRemaining?.Invoke(this, timeRemaining);
}
} }
} }