Skip to content

Commit

Permalink
Added HttpGoodOutcome and HttpBadOutcome
Browse files Browse the repository at this point in the history
  • Loading branch information
md-redwan-hossain committed Oct 4, 2024
1 parent 51644e3 commit 36e4772
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/SharpOutcome/Helpers/BadOutcomeWithPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public readonly record struct BadOutcomeWithPayload<TPayload>(
/// <param name="Payload">The payload that carries contextual data.</param>
/// <typeparam name="TPayload">The type of the payload.</typeparam>
/// <param name="Reason">The reason for the bad outcome (optional).</param>
public readonly record struct BadOutcomeWithPayload<TPayload, TOutcomeTag>(
public readonly record struct BadOutcomeWithPayload<TOutcomeTag, TPayload>(
TOutcomeTag Tag,
TPayload Payload,
string? Reason = null
) : IBadOutcomeWithPayload<TPayload, TOutcomeTag>;
) : IBadOutcomeWithPayload<TOutcomeTag, TPayload>;
4 changes: 2 additions & 2 deletions src/SharpOutcome/Helpers/GoodOutcomeWithPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public readonly record struct GoodOutcomeWithPayload<TPayload>(
/// <typeparam name="TPayload">The type of the payload.</typeparam>
/// <param name="Payload">The payload that carries contextual data.</param>
/// <param name="Reason">The reason for the good outcome (optional).</param>
public readonly record struct GoodOutcomeWithPayload<TPayload, TOutcomeTag>(
public readonly record struct GoodOutcomeWithPayload<TOutcomeTag, TPayload>(
TOutcomeTag Tag,
TPayload Payload,
string? Reason = null
) : IGoodOutcomeWithPayload<TPayload, TOutcomeTag>;
) : IGoodOutcomeWithPayload<TOutcomeTag, TPayload>;
18 changes: 18 additions & 0 deletions src/SharpOutcome/Helpers/HttpBadOutcome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace SharpOutcome.Helpers;

/// <summary>
/// Represents an HTTP bad outcome.
/// </summary>
/// <param name="Tag">The unique tag of the bad outcome.</param>
/// <param name="Reason">The reason for the bad outcome (optional).</param>
public readonly record struct HttpBadOutcome(HttpBadOutcomeTag Tag, string? Reason) : IBadOutcome<HttpBadOutcomeTag>;

/// <summary>
/// Represents an HTTP bad outcome with a payload of type <typeparamref name="TPayload"/>.
/// </summary>
/// <param name="Tag">The unique tag of the bad outcome.</param>
/// <typeparam name="TPayload">The type of the payload.</typeparam>
/// <param name="Payload">The payload that carries contextual data.</param>
/// <param name="Reason">The reason for the bad outcome (optional).</param>
public readonly record struct HttpBadOutcome<TPayload>(HttpBadOutcomeTag Tag, TPayload Payload, string? Reason)
: IBadOutcomeWithPayload<HttpBadOutcomeTag, TPayload>;
19 changes: 19 additions & 0 deletions src/SharpOutcome/Helpers/HttpGoodOutcome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace SharpOutcome.Helpers;

/// <summary>
/// Represents an HTTP good outcome.
/// </summary>
/// <param name="Tag">The unique tag of the good outcome.</param>
/// <param name="Reason">The reason for the good outcome (optional).</param>
public readonly record struct HttpGoodOutcome(HttpGoodOutcomeTag Tag, string? Reason)
: IGoodOutcome<HttpGoodOutcomeTag>;

/// <summary>
/// Represents an HTTP good outcome with a payload of type <typeparamref name="TPayload"/>.
/// </summary>
/// <param name="Tag">The unique tag of the good outcome.</param>
/// <typeparam name="TPayload">The type of the payload.</typeparam>
/// <param name="Payload">The payload that carries contextual data.</param>
/// <param name="Reason">The reason for the good outcome (optional).</param>
public readonly record struct HttpGoodOutcome<TPayload>(HttpGoodOutcomeTag Tag, TPayload Payload, string? Reason)
: IGoodOutcomeWithPayload<HttpGoodOutcomeTag, TPayload>;
2 changes: 1 addition & 1 deletion src/SharpOutcome/Helpers/IBadOutcomeWithPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IBadOutcomeWithPayload<out TPayload>
/// <summary>
/// Enforces a contract for bad outcome with payload of type <typeparamref name="TPayload"/>.
/// </summary>
public interface IBadOutcomeWithPayload<out TPayload, out TOutcomeTag>
public interface IBadOutcomeWithPayload< out TOutcomeTag,out TPayload>
{
/// <summary>
/// Gets the unique tag of the bad outcome.
Expand Down
3 changes: 1 addition & 2 deletions src/SharpOutcome/Helpers/IGoodOutcomeWithPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ public interface IGoodOutcomeWithPayload<out TPayload>
string? Reason { get; }
}


/// <summary>
/// Enforces a contract for good outcome with payload of type <typeparamref name="TPayload"/>.
/// </summary>
public interface IGoodOutcomeWithPayload<out TPayload, out TOutcomeTag>
public interface IGoodOutcomeWithPayload<out TOutcomeTag, out TPayload>
{
/// <summary>
/// Gets the unique tag of the good outcome.
Expand Down
4 changes: 2 additions & 2 deletions src/SharpOutcome/SharpOutcome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<Version>0.0.12</Version>
<Version>1.0.0</Version>
<Title>SharpOutcome</Title>
<Authors>Md. Redwan Hossain</Authors>
<Copyright>Copyright (c) Md. Redwan Hossain</Copyright>
Expand Down Expand Up @@ -35,6 +35,6 @@
<PackagePath>.</PackagePath>
</None>
</ItemGroup>


</Project>

0 comments on commit 36e4772

Please sign in to comment.