Geekeey.Request.Result (2.0.0)

Published 2026-05-30 18:06:41 +00:00 by HeyGeekeey in geekeey/request

Installation

dotnet nuget add source --name geekeey --username your_username --password your_token 
dotnet add package --source geekeey --version 2.0.0 Geekeey.Request.Result

About this package

Simple result type implementation for C# with utilities for composing success and failure flows.

Features

  • Success and Failure States: Represent successful outcomes with a value (Prelude.Success()) or failures with an error (Prelude.Failure()).
  • Immutability: Result<T> objects are immutable, ensuring thread safety and preventing accidental modification.
  • Chaining Operations: Methods like Map and Then allow for chaining operations on successful results, promoting a functional programming style.

Getting Started

Install the NuGet package:

dotnet add package Geekeey.Request.Result

You may need to add our NuGet feed to your nuget.config this can be done by running the following command:

dotnet nuget add source -n geekeey https://code.geekeey.de/api/packages/geekeey/nuget/index.json

Usage

Basic success/failure handling:

public Result<int> Divide(int dividend, int divisor)
{
  return divisor == 0
    ? Prelude.Failure<int>("Division by zero")
    : Prelude.Success(dividend / divisor);
}

var result = Divide(10, 2);
var message = result.IsSuccess
  ? $"Result: {result.Value}"
  : $"Error: {result.Error}";

Chaining with Map and Then:

var result = Prelude.Success(10)
  .Map(x => x * 2)           // 20
  .Map(x => x + 5)           // 25
  .Then(x => x > 20          
    ? Prelude.Success(x)
    : Prelude.Failure<int>("Value too small"));

Async operations with error handling:

public async Task<Result<User>> FetchUserAsync(int userId)
{
  return await Prelude.TryAsync(() => _httpClient.GetAsync($"/api/users/{userId}"))
    .ThenAsync(static async response =>
    {
      var json = await response.Content.ReadAsStringAsync();
      return Prelude.Try(() => JsonSerializer.Deserialize<User>(json)!);
    });
}

Collecting multiple results:

var results = await Task.WhenAll(userIds.Select(FetchUserAsync));
var combined = results.Join(); // Result<IReadOnlyList<User>>

if (combined.IsSuccess)
{
  foreach (var user in combined.Value)
  {
    Console.WriteLine($"User: {user.Name}");
  }
}
Details
NuGet
2026-05-30 18:06:41 +00:00
3
The Geekeey Team
110 KiB
Assets (4)
Versions (3) View all
2.0.0 2026-05-30
1.1.0 2026-05-28
1.0.0 2026-05-26