AddAllWhizbangServices¶
Verified by tests
ServiceRegistrationGeneratorTests — library CI run #31657041675 (2026-08-13)
AddAllWhizbangServices is a convenience method that registers all discovered Perspective and Lens implementations with the dependency injection container in a single call. All registrations are Transient.
Updated
Calling this method explicitly is usually unnecessary: AddWhizbang() auto-invokes the generated registrations via ServiceRegistrationCallbacks when your assembly loads. Use the explicit call when you register services without AddWhizbang(), or configure auto-registration through options.Services instead (see ServiceRegistrationOptions).
Signature¶
Signature
public static IServiceCollection AddAllWhizbangServices(
this IServiceCollection services,
Action<ServiceRegistrationOptions>? configure = null)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
services |
IServiceCollection |
The service collection to add registrations to |
configure |
Action<ServiceRegistrationOptions>? |
Optional configuration action |
Returns¶
IServiceCollection - The service collection for method chaining.
Behavior¶
This method is equivalent to calling both registration methods with the same options:
Behavior
Basic Usage¶
Register All Services
var builder = WebApplication.CreateBuilder(args);
// Register all discovered Perspectives and Lenses
builder.Services.AddAllWhizbangServices();
With Options¶
Register with Options
// Disable self-registration for all services
builder.Services.AddAllWhizbangServices(options =>
options.IncludeSelfRegistration = false);
Complete Setup Example¶
Full Application Setup
var builder = WebApplication.CreateBuilder(args);
// 1. Configure database
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
// 2. Add core Whizbang services (auto-registers discovered services)
builder.Services.AddWhizbang(options => {
options.Tags.UseHook<SignalTagAttribute, SignalRNotificationHook<NotificationHub>>();
});
// 3. Register perspective runners (for perspective materialization)
builder.Services.AddWhizbangPerspectives();
var app = builder.Build();
When to Use¶
Use AddAllWhizbangServices when:
- You want all Perspectives and Lenses registered
- You want consistent options for all services
- You prefer a single registration call
Use individual methods when: - You need different options for Perspectives vs Lenses - You only want to register one type of service - You need more granular control
Individual Registration
// Different options for each service type
builder.Services.AddPerspectiveServices(options =>
options.IncludeSelfRegistration = true);
builder.Services.AddLensServices(options =>
options.IncludeSelfRegistration = false);
Method Chaining¶
The method returns IServiceCollection for fluent configuration:
Method Chaining
builder.Services
.AddPerspectiveServices()
.AddLensServices();
// Note: AddWhizbang() returns a WhizbangBuilder (for storage configuration
// chaining like .WithEFCore<T>()), not IServiceCollection — call it as a
// separate statement.
See Also¶
- ServiceRegistrationOptions - Configuration options
- ServiceRegistrationExtensions - Parent class
- AddPerspectiveServices - Register only Perspectives
- AddLensServices - Register only Lenses
- WhizbangCoreOptions - Core configuration