Space.DependencyInjection
2.2.0
See the version list below for details.
dotnet add package Space.DependencyInjection --version 2.2.0
NuGet\Install-Package Space.DependencyInjection -Version 2.2.0
<PackageReference Include="Space.DependencyInjection" Version="2.2.0" />
<PackageVersion Include="Space.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Space.DependencyInjection" />
paket add Space.DependencyInjection --version 2.2.0
#r "nuget: Space.DependencyInjection, 2.2.0"
#:package Space.DependencyInjection@2.2.0
#addin nuget:?package=Space.DependencyInjection&version=2.2.0
#tool nuget:?package=Space.DependencyInjection&version=2.2.0
Space.DependencyInjection
Dependency Injection extensions and runtime implementations for the Space framework. Provides the AddSpace entry point that wires up all discovered handlers, pipelines, notifications and system modules without runtime reflection.
Install
dotnet add package Space.Abstraction # brings attributes + source generator analyzer
dotnet add package Space.DependencyInjection # brings DI extensions + ISpace implementation
Root Aggregator (Multi-Project)
- Mark exactly one project as root aggregator:
<PropertyGroup>
<SpaceGenerateRootAggregator>true</SpaceGenerateRootAggregator>
</PropertyGroup>
- That root project MUST reference BOTH
Space.AbstractionandSpace.DependencyInjection. - Satellite libraries that only contain handlers/pipelines/notifications should reference
Space.Abstractionto bring the analyzer (DI package is optional for them).
Quick Start
var services = new ServiceCollection();
services.AddSpace(options =>
{
options.ServiceLifetime = ServiceLifetime.Scoped; // Lifetime of generated registrations
options.NotificationDispatchType = NotificationDispatchType.Parallel; // or Sequential
});
// Optional built�in module providers
services.AddSpaceInMemoryCache(); // if using InMemoryCache module package
var provider = services.BuildServiceProvider();
var space = provider.GetRequiredService<ISpace>();
// Send a request
var loginResponse = await space.Send<UserLoginResponse>(new UserLoginRequest("demo"));
// Publish an event (all [Notification] handlers of matching event type will be invoked)
await space.Publish(new UserLoggedInSuccessfully("demo"));
Named Handlers
If multiple [Handle] methods target the same request/response, give them distinct Name values and select at call time:
var result = await space.Send<PriceResult>(query /* request object */, name: "Discounted");
Modules
Framework & custom modules are activated by annotating handler methods with their module attribute (e.g. [CacheModule(Duration = 60)]). System modules run before user pipelines. Add supporting package/providers before calling the handler.
In-Memory Cache Example
services.AddSpace();
services.AddSpaceInMemoryCache();
public class UserQueries
{
[Handle]
[CacheModule(Duration = 30)]
public ValueTask<UserDetail> GetUser(HandlerContext<UserId> ctx) => ...;
}
Source-Generated Extensions (Internal)
The generator (included via Space.Abstraction) emits and AddSpace invokes:
AddSpaceSourceGenerated(IServiceCollection, Action<SpaceOptions>?)AddSpaceModules(IServiceCollection)You normally just callservices.AddSpace(...).
Notifications
Configure dispatch strategy via SpaceOptions.NotificationDispatchType (Parallel or Sequential). Each [Notification] method receives a NotificationContext<TEvent>.
Pipelines
Add cross�cutting logic with [Pipeline] methods using PipelineContext<TRequest>; use Order to influence execution relative to other pipelines (modules use very low values to run first).
Performance
No runtime reflection: all registrations & handler metadata are generated at build time for minimal overhead.
Links
- Repo: https://github.com/salihcantekin/Space
- License: MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.7)
- Space.Abstraction (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.3.1 | 354 | 12/25/2025 | |
| 2.3.1-preview | 165 | 12/20/2025 | |
| 2.3.0 | 155 | 12/20/2025 | |
| 2.3.0-preview | 329 | 12/7/2025 | |
| 2.2.0 | 340 | 11/26/2025 | |
| 2.2.0-preview | 177 | 11/8/2025 | |
| 2.1.0-preview | 159 | 11/7/2025 | |
| 2.0.0 | 488 | 10/2/2025 | |
| 2.0.0-preview | 170 | 9/27/2025 | |
| 1.3.4-preview | 280 | 9/19/2025 | |
| 1.3.3 | 409 | 9/19/2025 | |
| 1.3.3-preview | 341 | 9/18/2025 | |
| 1.3.2-preview | 335 | 9/18/2025 | |
| 1.3.1 | 536 | 9/16/2025 | |
| 1.3.1-preview | 185 | 9/13/2025 | |
| 1.3.0-preview | 190 | 9/13/2025 | |
| 1.2.2 | 189 | 9/13/2025 | |
| 1.2.1-preview | 154 | 9/12/2025 | |
| 1.2.0-preview | 171 | 9/12/2025 |