fluent API
An API designed so each call returns an object you can call the next method on, letting configuration read as one chained sentence.
In more detail
Each call configures one thing, so the chain reads top to bottom as a list of settings. services.AddOptions<CatalogOptions>().BindConfiguration(...).ValidateOnStart() and FluentValidation's RuleFor(...).NotEmpty() are fluent APIs.
Related terms
- extension method — A static method whose first parameter is marked this, so it can be called as though it were an instance method of that type.
- AddOptions — The registration call, services.AddOptions<T>(), that returns an options builder on which binding and validation calls are chained.
- FluentValidation — A .NET library for writing validation rules as classes with a fluent API, such as RuleFor(x => x.Price).GreaterThan(0).
Taught in
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices
- Model Validation and FluentValidation — Modern .NET Core, C# & Enterprise Microservices