Skip to content

Commit 1f8ba95

Browse files
committed
Refactor Result classes to use immutable pattern and rename Ok to Success
1 parent 48ba706 commit 1f8ba95

8 files changed

Lines changed: 247 additions & 296 deletions

File tree

samples/ModularMonolithSample/src/Orders.Module/Extensions/ResultExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static Microsoft.AspNetCore.Http.IResult ToHttpResult(this Result result)
99
{
1010
return result.Status switch
1111
{
12-
ResultStatus.Ok => Results.NoContent(),
12+
ResultStatus.Success => Results.NoContent(),
1313
ResultStatus.NoContent => Results.NoContent(),
1414
ResultStatus.NotFound => Results.NotFound(new { message = result.Message }),
1515
ResultStatus.Invalid => Results.BadRequest(new { message = result.Message, errors = result.ValidationErrors }),
@@ -25,7 +25,7 @@ public static Microsoft.AspNetCore.Http.IResult ToHttpResult<T>(this Result<T> r
2525
{
2626
return result.Status switch
2727
{
28-
ResultStatus.Ok => Results.Ok(result.Value),
28+
ResultStatus.Success => Results.Ok(result.Value),
2929
ResultStatus.Created => Results.Ok(result.Value),
3030
ResultStatus.NotFound => Results.NotFound(new { message = result.Message }),
3131
ResultStatus.Invalid => Results.BadRequest(new { message = result.Message, errors = result.ValidationErrors }),
@@ -41,7 +41,7 @@ public static Microsoft.AspNetCore.Http.IResult ToCreatedResult<T>(this Result<T
4141
{
4242
return result.Status switch
4343
{
44-
ResultStatus.Ok => Results.Created(location, result.Value),
44+
ResultStatus.Success => Results.Created(location, result.Value),
4545
ResultStatus.Created => Results.Created(location, result.Value),
4646
ResultStatus.NotFound => Results.NotFound(new { message = result.Message }),
4747
ResultStatus.Invalid => Results.BadRequest(new { message = result.Message, errors = result.ValidationErrors }),

src/Foundatio.Mediator.Abstractions/Foundatio.Mediator.Abstractions.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\..\build\common.props" />
3+
<PropertyGroup>
4+
<RootNamespace>Foundatio.Mediator</RootNamespace>
5+
</PropertyGroup>
36

47
<ItemGroup>
58
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />

src/Foundatio.Mediator.Abstractions/IResult.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ public interface IResult
1515
/// </summary>
1616
bool IsSuccess { get; }
1717

18-
/// <summary>
19-
/// Gets the type of the result value.
20-
/// </summary>
21-
Type ValueType { get; }
22-
2318
/// <summary>
2419
/// Gets the result value as an object.
2520
/// </summary>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.ComponentModel;
2+
3+
namespace System.Runtime.CompilerServices;
4+
5+
[EditorBrowsable(EditorBrowsableState.Never)]
6+
internal static class IsExternalInit;

0 commit comments

Comments
 (0)