Space.DependencyInjection
1.1.11
See the version list below for details.
dotnet add package Space.DependencyInjection --version 1.1.11
NuGet\Install-Package Space.DependencyInjection -Version 1.1.11
<PackageReference Include="Space.DependencyInjection" Version="1.1.11" />
<PackageVersion Include="Space.DependencyInjection" Version="1.1.11" />
<PackageReference Include="Space.DependencyInjection" />
paket add Space.DependencyInjection --version 1.1.11
#r "nuget: Space.DependencyInjection, 1.1.11"
#:package Space.DependencyInjection@1.1.11
#addin nuget:?package=Space.DependencyInjection&version=1.1.11
#tool nuget:?package=Space.DependencyInjection&version=1.1.11
Space.DependencyInjection
Dependency Injection extensions + source generator bootstrap 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.DependencyInjection
(Brings in Space.Abstraction
.)
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 */, handlerName: "Discounted");
(The overload with handlerName
is source?generated.)
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 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 (>= 1.1.11)
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 | |
---|---|---|---|
1.1.12-preview | 59 | 9/7/2025 | |
1.1.11 | 67 | 9/7/2025 | |
1.1.10 | 63 | 9/7/2025 | |
1.1.9 | 69 | 9/6/2025 | |
1.1.8 | 121 | 9/5/2025 | |
0.1.1-preview.6 | 21 | 9/7/2025 | |
0.1.1-preview.5 | 28 | 9/7/2025 |