Skip to content

Commit

Permalink
Result.From(bool)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSemenenko committed Jun 14, 2024
1 parent f154779 commit be3a6a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<RepositoryUrl>https://github.com/managedcode/Communication</RepositoryUrl>
<PackageProjectUrl>https://github.com/managedcode/Communication</PackageProjectUrl>
<Product>Managed Code - Communication</Product>
<Version>8.0.2</Version>
<PackageVersion>8.0.2</PackageVersion>
<Version>8.0.3</Version>
<PackageVersion>8.0.3</PackageVersion>

</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
20 changes: 20 additions & 0 deletions ManagedCode.Communication/Result/Result.From.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,24 @@ public static async Task<Result> From(Func<ValueTask> valueTask)
return Fail(Error.FromException(e));
}
}

public static Result From(bool condition)
{
return condition ? Succeed() : Fail();
}

public static Result From(bool condition, Error error)
{
return condition ? Succeed() : Fail(error);
}

public static Result From(Func<bool> condition)
{
return condition() ? Succeed() : Fail();
}

public static Result From(Func<bool> condition, Error error)
{
return condition() ? Succeed() : Fail(error);
}
}

0 comments on commit be3a6a7

Please sign in to comment.