Olve.Operations
0.38.0
dotnet add package Olve.Operations --version 0.38.0
NuGet\Install-Package Olve.Operations -Version 0.38.0
<PackageReference Include="Olve.Operations" Version="0.38.0" />
<PackageVersion Include="Olve.Operations" Version="0.38.0" />
<PackageReference Include="Olve.Operations" />
paket add Olve.Operations --version 0.38.0
#r "nuget: Olve.Operations, 0.38.0"
#:package Olve.Operations@0.38.0
#addin nuget:?package=Olve.Operations&version=0.38.0
#tool nuget:?package=Olve.Operations&version=0.38.0
Olve.Operations
Deprecated: This package is no longer maintained. The abstractions it provides add little value over plain method signatures or
Func<TRequest, Result>. Consider using simple interfaces or delegates instead.
Abstractions for implementing operations that return Result objects. Provides sync and async variants, with optional return values and DI-based factories.
Installation
dotnet add package Olve.Operations
Overview
| Type | Description |
|---|---|
IOperation<TRequest> |
Synchronous operation returning Result. |
IOperation<TRequest, TResult> |
Synchronous operation returning Result<TResult>. |
IAsyncOperation<TRequest> |
Async operation returning Task<Result>. |
IAsyncOperation<TRequest, TResult> |
Async operation returning Task<Result<TResult>>. |
OperationFactory<TOperation, TRequest> |
DI factory for sync operations. |
AsyncOperationFactory<TOperation, TRequest> |
DI factory for async operations. |
Usage
Synchronous operation
Implement IOperation<TRequest> for operations that don't return a value.
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L67-L70
private class GreetOperation : IOperation<string>
{
public Result Execute(string request) => Result.Success();
}
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L11-L15
var op = new GreetOperation();
var result = op.Execute("Alice");
await Assert.That(result.Succeeded).IsTrue();
Synchronous operation with return value
Implement IOperation<TRequest, TResult> when the operation produces a typed result.
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L72-L78
private class DoubleOperation : IOperation<int, int>
{
public Result<int> Execute(int request) => request * 2;
public class Factory(IServiceProvider sp)
: OperationFactory<DoubleOperation, int, int>(sp);
}
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L21-L26
var op = new DoubleOperation();
var result = op.Execute(21);
await Assert.That(result.Succeeded).IsTrue();
await Assert.That(result.Value).IsEqualTo(42);
Async operation
Implement IAsyncOperation<TRequest> for async work. All async variants accept an optional CancellationToken.
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L80-L87
private class SlowGreetOperation : IAsyncOperation<string>
{
public async Task<Result> ExecuteAsync(string request, CancellationToken ct = default)
{
await Task.Delay(1, ct);
return Result.Success();
}
}
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L32-L36
var op = new SlowGreetOperation();
var result = await op.ExecuteAsync("Bob");
await Assert.That(result.Succeeded).IsTrue();
Async operation with return value
IAsyncOperation<TRequest, TResult> combines async execution with a typed result.
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L89-L96
private class AsyncDoubleOperation : IAsyncOperation<int, int>
{
public async Task<Result<int>> ExecuteAsync(int request, CancellationToken ct = default)
{
await Task.Delay(1, ct);
return request * 2;
}
}
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L42-L47
var op = new AsyncDoubleOperation();
var result = await op.ExecuteAsync(21);
await Assert.That(result.Succeeded).IsTrue();
await Assert.That(result.Value).IsEqualTo(42);
Factory pattern with DI
Define a nested Factory class inheriting from OperationFactory (or AsyncOperationFactory). Register both the operation and factory in your DI container, then call Build() to resolve instances.
// ../../tests/Olve.Operations.Tests/ReadmeDemo.cs#L53-L62
var services = new ServiceCollection();
services.AddTransient<DoubleOperation>();
services.AddTransient<DoubleOperation.Factory>();
using var sp = services.BuildServiceProvider();
var factory = sp.GetRequiredService<DoubleOperation.Factory>();
var op = factory.Build();
var result = op.Execute(21);
await Assert.That(result.Value).IsEqualTo(42);
Documentation
Full API reference: https://olivervea.github.io/Olve.Utilities/api/Olve.Operations.html
License
MIT License © OliverVea
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Olve.Results (>= 0.38.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Olve.Operations:
| Package | Downloads |
|---|---|
|
Olve.OpenRaster
lightweight native support for OpenRaster files |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.38.0 | 215 | 2/19/2026 |
| 0.37.2 | 95 | 2/18/2026 |
| 0.37.1 | 94 | 2/18/2026 |
| 0.37.0 | 94 | 2/17/2026 |
| 0.36.1 | 271 | 11/15/2025 |
| 0.36.0 | 192 | 11/15/2025 |
| 0.35.2 | 153 | 11/9/2025 |
| 0.35.1 | 146 | 11/8/2025 |
| 0.35.0 | 133 | 11/8/2025 |
| 0.34.0 | 136 | 10/4/2025 |
| 0.33.0 | 134 | 9/13/2025 |
| 0.32.2 | 199 | 8/9/2025 |
| 0.32.1 | 180 | 8/9/2025 |
| 0.32.0 | 239 | 8/8/2025 |
| 0.31.0 | 267 | 8/5/2025 |
| 0.30.0 | 109 | 8/3/2025 |
| 0.29.1 | 103 | 8/3/2025 |
| 0.29.0 | 90 | 8/3/2025 |
| 0.28.2 | 83 | 8/2/2025 |
| 0.26.2 | 524 | 7/21/2025 |