Sumapap.DependencyInjection
1.1.1
dotnet add package Sumapap.DependencyInjection --version 1.1.1
NuGet\Install-Package Sumapap.DependencyInjection -Version 1.1.1
<PackageReference Include="Sumapap.DependencyInjection" Version="1.1.1" />
<PackageVersion Include="Sumapap.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Sumapap.DependencyInjection" />
paket add Sumapap.DependencyInjection --version 1.1.1
#r "nuget: Sumapap.DependencyInjection, 1.1.1"
#:package Sumapap.DependencyInjection@1.1.1
#addin nuget:?package=Sumapap.DependencyInjection&version=1.1.1
#tool nuget:?package=Sumapap.DependencyInjection&version=1.1.1
Sumapap.DependencyInjection
💡 Overview
Sumapap.DependencyInjection provides a fluent builder pattern for configuring Sumapap services with Microsoft Dependency Injection. It serves as the foundation for the Sumapap ecosystem's extension point architecture, enabling each library to contribute its own registration methods through a consistent, chainable API.
Core abstractions included:
- IBuilder<T> generic builder interface for fluent configuration patterns.
- SumapapServiceBuilder concrete builder implementation wrapping IServiceCollection.
- ServiceExtensions.AddSumapap() entry point for starting fluent configuration.
✨ Why use Sumapap.DependencyInjection?
- Provides a consistent, fluent API for configuring all Sumapap libraries in your application.
- Enables each Sumapap package to extend the builder with its own registration methods without circular dependencies.
- Promotes discoverability IDE IntelliSense guides you through available configuration options as you chain methods.
- Separates DI orchestration from individual library implementations, keeping concerns focused.
- Supports clean, readable service registration in Program.cs or Startup.cs.
🚀 Quick start
Add the package to your project (when published on NuGet):
dotnet add package Sumapap.DependencyInjectionUse the fluent builder in your application startup:
using Sumapap.DependencyInjection; var builder = WebApplication.CreateBuilder(args); // Start Sumapap configuration var sumapapBuilder = builder.Services.AddSumapap(); // Each Sumapap library extends the builder // (Examples require respective packages to be installed) // sumapapBuilder.AddPersistence(...) // sumapapBuilder.AddDomainEvents(...) // sumapapBuilder.AddQueries(...) var app = builder.Build();Access the underlying IServiceCollection if needed:
var services = sumapapBuilder.Build(); // Continue with manual service registrations if neededExtension pattern individual libraries extend SumapapServiceBuilder:
public static class PersistenceExtensions { public static SumapapServiceBuilder AddPersistence( this SumapapServiceBuilder builder, Action<PersistenceOptions> configure) { // Configure persistence services var services = builder.Build(); services.AddScoped<IUnitOfWork, UnitOfWork>(); return builder; } }
⭐ License
Distributed under the MIT License. See the LICENSE file in the repository for more information.
🚩 Contact
GitHub @muhammadirwanto-dev
Project Url https://github.com/muhammadirwanto-dev/sumapap/tree/main/src/Sumapap.Ddd.Dispatcher
☕ Support
If you like this project and want to support it, you can buy me a coffee︎. Your coffee will keep me awake while developing this project ☕.
<p align="center"> <a href="https://buymeacoffee.com/muhirwanto.dev"> <img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=&slug=muhirwanto.dev&button_colour=FFDD00&font_colour=000000&font_family=Comic&outline_colour=000000&coffee_colour=ffffff" alt="Buy Me A Coffee"> </a> </p>
🛠 Features and usage
IBuilder<T>
- Generic interface defining the builder pattern contract.
- Single method: T Build() returns the built instance.
- Can be used for any fluent configuration scenario beyond Sumapap.
SumapapServiceBuilder
- Concrete builder wrapping IServiceCollection.
- Primary entry point for Sumapap configuration.
- Implements IBuilder<IServiceCollection>.
- Enables method chaining by returning itself from extension methods.
- Access underlying services via Build() method.
ServiceExtensions
- Entry point: AddSumapap() extension method on IServiceCollection.
- Returns SumapapServiceBuilder to start fluent configuration chain.
- Validates input (throws ArgumentNullException if services is null).
Extension Point Architecture
Each Sumapap library extends SumapapServiceBuilder with its own methods:
- AddPersistence(...) from Sumapap.Persistence
- AddDomainEvents(...) from Sumapap.Ddd.Dispatcher or Sumapap.Ddd.Mediator
- AddQueries(...) from Sumapap.Queries
- Libraries access IServiceCollection via builder.Build() internally
- Return the builder to enable continued chaining
⚠️ Notes & best practices
- No circular dependencies This package depends only on Microsoft.Extensions.DependencyInjection.Abstractions. Individual Sumapap libraries reference this package and extend it, not vice versa.
- Extension methods Keep extension methods in dedicated static classes with clear naming (e.g., PersistenceExtensions, DomainEventsExtensions).
- Return the builder Always return SumapapServiceBuilder from extension methods to enable chaining.
- Access services internally Extension methods should call builder.Build() to get IServiceCollection for registration, but never expose it directly in fluent API.
- Validation Use ArgumentNullException.ThrowIfNull() to validate builder parameter in extension methods.
- Configuration delegates Prefer Action<TOptions> parameters for complex configuration scenarios to keep APIs clean.
- Discoverability Use XML documentation on all extension methods to provide IntelliSense guidance.
✅ Example
// Program.cs
using Sumapap.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
// Fluent Sumapap configuration
builder.Services
.AddSumapap()
// Extensions from other Sumapap packages
.AddPersistence(opts => opts.UseEfCore<AppDbContext>())
.AddDomainEvents()
.AddQueries();
var app = builder.Build();
app.Run();
// Custom extension (in your library)
public static class MyLibraryExtensions
{
/// <summary>
/// Adds My Library services to the Sumapap builder.
/// </summary>
public static SumapapServiceBuilder AddMyLibrary(
this SumapapServiceBuilder builder,
Action<MyLibraryOptions>? configure = null)
{
ArgumentNullException.ThrowIfNull(builder);
var services = builder.Build();
// Register services
services.AddScoped<IMyService, MyService>();
// Apply configuration
if (configure != null)
{
services.Configure(configure);
}
return builder;
}
}
⭐ License
Distributed under the MIT License. See the LICENSE file in the repository for more information.
🚩 Contact
GitHub @muhammadirwanto-dev
Project Url https://github.com/muhammadirwanto-dev/sumapap/tree/main/src/Sumapap.DependencyInjection
☕ Support
If you like this project and want to support it, you can buy me a coffee︎. Your coffee will keep me awake while developing this project ☕.
<p align="center"> <a href="https://buymeacoffee.com/muhirwanto.dev"> <img src="https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20coffee&emoji=&slug=muhirwanto.dev&button_colour=FFDD00&font_colour=000000&font_family=Comic&outline_colour=000000&coffee_colour=ffffff" alt="Buy Me A Coffee"> </a> </p>
| 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
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Sumapap.DependencyInjection:
| Package | Downloads |
|---|---|
|
Sumapap.Persistence
The `Sumapap.Persistence` package provides a set of tools and abstractions for implementing persistence in your applications. It includes features such as caching, database access, and integration with dependency injection frameworks. With Sumapap.Persistence, you can easily manage your application's data storage and retrieval while maintaining a clean and modular architecture. |
|
|
Sumapap.Ddd
This package provides a simple, convention-based Domain Event Dispatcher that automatically discovers and invokes all registered `IDomainEventHandlerT` implementations for any given `IDomainEvent`. By leveraging .NET's built-in dependency injection, it ensures seamless integration with your application's service container, allowing for clean separation of concerns and adherence to DDD principles without coupling your domain layer to specific frameworks. |
|
|
Sumapap.Caching
Provider-agnostic cache key generation abstractions for Sumapap packages. |
|
|
Sumapap.Reporting
The `Sumapap.Reporting` package provides a set of tools and abstractions for implementing reporting functionality in your applications. It includes features such as report generation, data visualization, and integration with various data sources. With Sumapap.Reporting, you can easily create and manage reports while maintaining a clean and modular architecture. |
GitHub repositories
This package is not used by any popular GitHub repositories.