-
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.
- Loading branch information
1 parent
92f06ce
commit f497d83
Showing
7 changed files
with
87 additions
and
0 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
14 changes: 14 additions & 0 deletions
14
src/Codehard.Functional/Codehard.Functional.Mediatr/Codehard.Functional.Mediatr.csproj
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LanguageExt.Core" Version="4.4.7" /> | ||
<PackageReference Include="MediatR" Version="12.1.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
32 changes: 32 additions & 0 deletions
32
src/Codehard.Functional/Codehard.Functional.Mediatr/ExpectedResultError.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,32 @@ | ||
using LanguageExt; | ||
using LanguageExt.Common; | ||
|
||
using static LanguageExt.Prelude; | ||
|
||
namespace Codehard.Functional.Mediatr; | ||
|
||
public record ExpectedResultError : Expected | ||
{ | ||
public ExpectedResultError(object errorObject, Error? inner) | ||
: base(string.Empty, 0, Optional(inner)) | ||
{ | ||
this.ErrorObject = errorObject; | ||
} | ||
|
||
public ExpectedResultError(object errorObject, Exception? exception = null) | ||
: base(string.Empty, 0, exception == null ? Option<Error>.None : Option<Error>.Some(ErrorException.New(exception))) | ||
{ | ||
this.ErrorObject = errorObject; | ||
} | ||
|
||
public override ErrorException ToErrorException() => ErrorException.New(this.ErrorObject.ToString() ?? string.Empty); | ||
|
||
public override string ToString() => this.ErrorObject.ToString() ?? string.Empty; | ||
|
||
public object ErrorObject { get; init; } | ||
|
||
public void Deconstruct(out object errorObject) | ||
{ | ||
errorObject = this.ErrorObject; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Codehard.Functional/Codehard.Functional.Mediatr/ICommand.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,8 @@ | ||
using LanguageExt; | ||
using MediatR; | ||
|
||
namespace Codehard.Functional.Mediatr; | ||
|
||
public interface ICommand<TCommandResult> : IRequest<Fin<TCommandResult>> | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Codehard.Functional/Codehard.Functional.Mediatr/ICommandHandler.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,9 @@ | ||
using LanguageExt; | ||
using MediatR; | ||
|
||
namespace Codehard.Functional.Mediatr; | ||
|
||
public interface ICommandHandler<in TCommand, TCommandResult> : IRequestHandler<TCommand, Fin<TCommandResult>> | ||
where TCommand : ICommand<TCommandResult> | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Codehard.Functional/Codehard.Functional.Mediatr/IQuery.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,8 @@ | ||
using LanguageExt; | ||
using MediatR; | ||
|
||
namespace Codehard.Functional.Mediatr; | ||
|
||
public interface IQuery<TQueryResult> : IRequest<Fin<TQueryResult>> | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Codehard.Functional/Codehard.Functional.Mediatr/QueryHandler.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,9 @@ | ||
using LanguageExt; | ||
using MediatR; | ||
|
||
namespace Codehard.Functional.Mediatr; | ||
|
||
public interface IQueryHandler<in TQuery, TQueryResult> : IRequestHandler<TQuery, Fin<TQueryResult>> | ||
where TQuery : IQuery<TQueryResult> | ||
{ | ||
} |