-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from NerosoftDev/develop
Develop
- Loading branch information
Showing
51 changed files
with
858 additions
and
492 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
172 changes: 0 additions & 172 deletions
172
Source/Euonia.Application/Seedwork/IRequestContextAccessor.cs
This file was deleted.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
Source/Euonia.Application/UseCase/DefaultUseCasePresenter.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// The default implementation of <see cref="IUseCasePresenter{TOutput}"/>. | ||
/// </summary> | ||
/// <typeparam name="TOutput"></typeparam> | ||
public class DefaultUseCasePresenter<TOutput> : DisposableObject, | ||
IUseCasePresenter<TOutput> | ||
where TOutput : IUseCaseOutput | ||
{ | ||
/// <inheritdoc/> | ||
public event EventHandler<TOutput> OnSucceed; | ||
|
||
/// <inheritdoc/> | ||
public event EventHandler<Exception> OnFailed; | ||
|
||
/// <inheritdoc/> | ||
public event EventHandler OnCanceled; | ||
|
||
/// <inheritdoc/> | ||
public void Error(Exception exception) | ||
{ | ||
if (exception is OperationCanceledException) | ||
{ | ||
OnCanceled?.Invoke(this, EventArgs.Empty); | ||
} | ||
else | ||
{ | ||
OnFailed?.Invoke(this, exception); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Ok(TOutput output) | ||
{ | ||
Output = output; | ||
OnSucceed?.Invoke(this, output); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the output of the use case. | ||
/// </summary> | ||
public TOutput Output { get; private set; } | ||
|
||
/// <inheritdoc/> | ||
protected override void Dispose(bool disposing) | ||
{ | ||
OnSucceed = null; | ||
OnFailed = null; | ||
OnCanceled = null; | ||
} | ||
} |
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,6 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Represents a none input use case. | ||
/// </summary> | ||
public record EmptyUseCaseInput : IUseCaseInput; |
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,6 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Represents the use case should not return any output. | ||
/// </summary> | ||
public sealed record EmptyUseCaseOutput : IUseCaseOutput; |
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,40 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Defines an interface for use case. | ||
/// </summary> | ||
/// <typeparam name="TInput"></typeparam> | ||
/// <typeparam name="TOutput"></typeparam> | ||
public interface IUseCase<in TInput, TOutput> | ||
where TInput : IUseCaseInput | ||
where TOutput : IUseCaseOutput | ||
{ | ||
/// <summary> | ||
/// Executes the use case. | ||
/// </summary> | ||
/// <param name="input"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
Task<TOutput> ExecuteAsync(TInput input, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets the presenter of the use case. | ||
/// </summary> | ||
IUseCasePresenter<TOutput> Presenter { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Defines an interface for use case. | ||
/// </summary> | ||
/// <typeparam name="TInput"></typeparam> | ||
public interface IUseCase<in TInput> | ||
where TInput : IUseCaseInput | ||
{ | ||
/// <summary> | ||
/// Executes the use case. | ||
/// </summary> | ||
/// <param name="input"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
Task ExecuteAsync(TInput input, CancellationToken cancellationToken = default); | ||
} |
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,8 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Defines the input data structure of a use case. | ||
/// </summary> | ||
public interface IUseCaseInput | ||
{ | ||
} |
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,8 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Defines the structure of use case execute result. | ||
/// </summary> | ||
public interface IUseCaseOutput | ||
{ | ||
} |
13 changes: 13 additions & 0 deletions
13
Source/Euonia.Application/UseCase/IUseCaseOutputFailure.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Nerosoft.Euonia.Application; | ||
|
||
/// <summary> | ||
/// Represents the structure of use case output when it is failure. | ||
/// </summary> | ||
public interface IUseCaseOutputFailure | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="exception"></param> | ||
void Error(Exception exception); | ||
} |
Oops, something went wrong.