SignalRExtensions
NexusLabs.Needlr.SignalR¶
NexusLabs.Needlr.SignalR¶
SignalRExtensions Class¶
Extension methods for configuring SignalR hub registration via Needlr.
Inheritance System.Object 🡒 SignalRExtensions
Example¶
// Reflection-based (not AOT-safe)
app.UseSignalRHubsWithReflection();
// Source-generated (AOT-safe) — requires NexusLabs.Needlr.SignalR.Generators
app.MapGeneratedHubs();
Remarks¶
Two approaches are supported:
- Reflection-based (UseSignalRHubsWithReflection(this WebApplication, IPluginFactory, IEnumerable<Assembly>)): discovers and maps hubs at
runtime. Convenient but incompatible with AOT/trimmed builds.
- Source-generated (app.MapGeneratedHubs()): emits hub mappings at compile time.
Required for AOT/trimmed applications.
Methods¶
SignalRExtensions.AddSignalRHubRegistrationWithReflection(this IServiceCollection) Method¶
Adds the reflection-based SignalR hub registration plugin to the service collection.
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSignalRHubRegistrationWithReflection(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
Parameters¶
services Microsoft.Extensions.DependencyInjection.IServiceCollection
The service collection to configure.
Returns¶
Microsoft.Extensions.DependencyInjection.IServiceCollection
The service collection for chaining.
Remarks¶
This registers the SignalRHubRegistrationPlugin which uses reflection to discover and map SignalR hubs at runtime.
For AOT/trimmed applications, do not use this method. Instead,
call app.MapGeneratedHubs() directly after building the application.
SignalRExtensions.UseSignalRHubsWithReflection(this WebApplication, IPluginFactory, IEnumerable<Assembly>) Method¶
Registers SignalR hubs using reflection-based discovery.
public static Microsoft.AspNetCore.Builder.WebApplication UseSignalRHubsWithReflection(this Microsoft.AspNetCore.Builder.WebApplication app, NexusLabs.Needlr.IPluginFactory? pluginFactory=null, System.Collections.Generic.IEnumerable<System.Reflection.Assembly>? assemblies=null);
Parameters¶
app Microsoft.AspNetCore.Builder.WebApplication
The web application to configure.
pluginFactory NexusLabs.Needlr.IPluginFactory
The plugin factory to use for discovering hub registration plugins.
assemblies System.Collections.Generic.IEnumerable<System.Reflection.Assembly>
The assemblies to scan for hub registration plugins.
Returns¶
Microsoft.AspNetCore.Builder.WebApplication
The web application for chaining.
Remarks¶
This method uses reflection to discover IHubRegistrationPlugin implementations
and invoke MapHub<T>() at runtime.
For AOT/trimmed applications, use the source-generated approach instead: