Fluent builder interfaces and Kotlin-inspired scope extensions for .NET.
Interface for standalone builders that create objects via Build().
public class MyWidgetBuilder : IBuilder<Widget>
{
public Widget Build() => new Widget(_options);
}
// Usage
Widget widget = new MyWidgetBuilder()
.WithColor("blue")
.WithSize(10)
.Build();Interface for nested builders that return to a parent context via Done().
// Nested builder returns to parent after building
app.Map(route => route
.WithLiteral("deploy")
.WithParameter("env")
.Done()) // Returns to parent builder
.WithHandler(handler);Kotlin-inspired extension methods for fluent object manipulation.
Executes an action on the object and returns the original object. Useful for side effects during method chaining.
var builder = new AppBuilder()
.Also(b => Console.WriteLine("Building app..."))
.Configure(options);Configures the object and returns the original object. Semantically similar to Also but with clearer intent for configuration.
app.Map("status", handler)
.Apply(r => r.AsQuery());Transforms the object to a different type.
int length = "hello".Let(s => s.Length); // 5Executes an action on the object with no return value. Terminal operation in a method chain.
app.Build().Run(a => a.RunAsync(args));