Skip to content

Commit e920491

Browse files
Improved Result structure
1 parent 4a405db commit e920491

15 files changed

Lines changed: 27 additions & 37 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<IsPackable>true</IsPackable>
7-
<Version>2.1.17</Version>
7+
<Version>2.1.18</Version>
88
<Authors>Andrey Serdyuk</Authors>
99
<Company>TaskHub</Company>
1010
<PackageTags>#TaskHub</PackageTags>

TaskHub.Shared.Commands.Abstractions/Behavior/IBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TaskHub.Shared.Commands.Abstractions.Behavior;
55

66
public interface IBehavior<TCommand, TResult>
77
where TCommand : ICommand
8-
where TResult : IResult
8+
where TResult : Result
99
{
1010
Task<TResult> HandleAsync(TCommand command, Func<TCommand, CancellationToken, Task<TResult>> next, CancellationToken ct);
1111
}

TaskHub.Shared.Commands.Abstractions/Bus/ICommandsBus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ public interface ICommandsBus
77
{
88
Task<TResult> SendAsync<TCommand, TResult>(TCommand request, CancellationToken ct)
99
where TCommand : ICommand
10-
where TResult : IResult;
10+
where TResult : Result;
1111
}

TaskHub.Shared.Commands.Abstractions/Handler/ICommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TaskHub.Shared.Commands.Abstractions.Handler;
55

66
public interface ICommandHandler<in TRequest, TResponse>
77
where TRequest : ICommand
8-
where TResponse : IResult
8+
where TResponse : Result
99
{
1010
Task<TResponse> HandleAsync(TRequest request, CancellationToken ct);
1111
}

TaskHub.Shared.Commands.Bus/CommandsBus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed class CommandsBus(IServiceScopeFactory factory) : ICommandsBus
1414

1515
public async Task<TResult> SendAsync<TCommand, TResult>(TCommand request, CancellationToken ct)
1616
where TCommand : ICommand
17-
where TResult : IResult
17+
where TResult : Result
1818
{
1919
var invokerObj = _invokers.GetOrAdd((typeof(TCommand), typeof(TResult)), _ => CreateInvoker<TCommand, TResult>());
2020
var invoker = (Func<IServiceProvider, TCommand, CancellationToken, Task<TResult>>)invokerObj;
@@ -24,7 +24,7 @@ public async Task<TResult> SendAsync<TCommand, TResult>(TCommand request, Cancel
2424

2525
private static Func<IServiceProvider, TCommand, CancellationToken, Task<TResult>> CreateInvoker<TCommand, TResult>()
2626
where TCommand : ICommand
27-
where TResult : IResult =>
27+
where TResult : Result =>
2828
static async (sp, request, ct) =>
2929
{
3030
ct.ThrowIfCancellationRequested();

TaskHub.Shared.GeoCoding.Abstractions/Client/IGeoClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ namespace TaskHub.Shared.GeoCoding.Abstractions.Client;
66

77
public interface IGeoClient
88
{
9-
Task<DataResult<PlaceModel>> SearchAsync(Text city, CancellationToken ct);
9+
Task<ValueResult<PlaceModel>> SearchAsync(Text city, CancellationToken ct);
1010
}

TaskHub.Shared.GeoCoding.Abstractions/Service/IGeoService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ namespace TaskHub.Shared.GeoCoding.Abstractions.Service;
77

88
public interface IGeoService : IService
99
{
10-
Task<DataResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct);
10+
Task<ValueResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct);
1111
}

TaskHub.Shared.GeoCoding.Nominatim/Client/NominatimClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace TaskHub.Shared.GeoCoding.Nominatim.Client;
1111

1212
public class NominatimClient(HttpClient http) : IGeoClient
1313
{
14-
public async Task<DataResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct)
14+
public async Task<ValueResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct)
1515
{
1616
var res = await http.GetFromJsonAsync<List<NominatimModel>>(CityQuery.Create(query).ToString(), ct) ?? [];
1717
if (res.Count > 0)

TaskHub.Shared.GeoCoding.Nominatim/Service/NominatimService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace TaskHub.Shared.GeoCoding.Nominatim.Service;
88

99
public class NominatimService(IGeoClient client) : IGeoService
1010
{
11-
public async Task<DataResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct) =>
11+
public async Task<ValueResult<PlaceModel>> SearchAsync(Text query, CancellationToken ct) =>
1212
await client.SearchAsync(query, ct);
1313
}

TaskHub.Shared.Response/DataResult.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)