-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version 2.4.6643 build 31257 untested
- Loading branch information
1 parent
7384e00
commit 9e2d53a
Showing
46 changed files
with
10,265 additions
and
6,717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Moviebase.Core.MVP | ||
{ | ||
public abstract class PresenterBase | ||
public abstract class PresenterBase : IDisposable | ||
{ | ||
private CancellationTokenSource _cancellationToken; | ||
protected CancellationTokenSource CancellationToken; | ||
|
||
protected bool IsCancellationRequested => _cancellationToken != null && _cancellationToken.IsCancellationRequested; | ||
protected bool IsCancellationRequested => CancellationToken != null && CancellationToken.IsCancellationRequested; | ||
|
||
protected void RecreateCancellationToken() | ||
{ | ||
_cancellationToken?.Dispose(); | ||
_cancellationToken = new CancellationTokenSource(); | ||
CancellationToken?.Dispose(); | ||
CancellationToken = new CancellationTokenSource(); | ||
} | ||
|
||
protected abstract void UpdateUi(UiState state, int progressPercentage = -1); | ||
public abstract void UpdateUi(UiState state, int progressPercentage = -1); | ||
|
||
protected void CancelTask() | ||
{ | ||
_cancellationToken?.Cancel(); | ||
CancellationToken?.Cancel(); | ||
UpdateUi(UiState.Cancelling); | ||
} | ||
|
||
protected void ThrowIfCancellationRequested() | ||
{ | ||
_cancellationToken?.Token.ThrowIfCancellationRequested(); | ||
CancellationToken?.Token.ThrowIfCancellationRequested(); | ||
} | ||
|
||
protected void RunTask(Action action) | ||
#region IDisposable Support | ||
private bool _disposedValue; | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
RecreateCancellationToken(); | ||
Task.Run(() => | ||
if (_disposedValue) return; | ||
if (disposing) | ||
{ | ||
UpdateUi(UiState.Working); | ||
action.Invoke(); | ||
UpdateUi(UiState.Ready); | ||
}, _cancellationToken.Token); | ||
if (CancellationToken != null) CancellationToken.Dispose(); | ||
} | ||
|
||
CancellationToken = null; | ||
_disposedValue = true; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace Moviebase.Core.MVP | ||
{ | ||
public class ValidationSupportFactory | ||
{ | ||
private Action<string> _failAction; | ||
|
||
public ValidationSupportFactory(Action<string> action) | ||
{ | ||
_failAction = action; | ||
} | ||
|
||
public ValidationSupport Create() | ||
{ | ||
var support = new ValidationSupport(); | ||
support.SetCommonFailAction(_failAction); | ||
return support; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
Moviebase.Core/CsvExportMap.cs → Moviebase.Core/Services/CsvExportMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
Moviebase.Core/IPersistFileManager.cs → ...base.Core/Services/IPersistFileManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using Moviebase.Entities; | ||
|
||
namespace Moviebase.Core | ||
namespace Moviebase.Core.Services | ||
{ | ||
public interface IPersistFileManager | ||
{ | ||
TmdbResult Load(string path); | ||
void Save(string outputPath, TmdbResult entry); | ||
MovieEntry Load(string path); | ||
void Save(string outputPath, MovieEntry entry); | ||
bool HasPersistentData(string path); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Moviebase.Core/IThumbnailManager.cs → Moviebase.Core/Services/IThumbnailManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Moviebase.Core | ||
namespace Moviebase.Core.Services | ||
{ | ||
public interface IThumbnailManager | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.