Skip to content

Commit 33c58b8

Browse files
committed
Support configuring hub options
1 parent 6a0dc64 commit 33c58b8

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

src/Components/Endpoints/src/DependencyInjection/IRazorComponentsBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
namespace Microsoft.AspNetCore.Components.Endpoints;
77

88
/// <summary>
9-
///
9+
/// A builder that can be used to configure Razor Components.
1010
/// </summary>
1111
public interface IRazorComponentsBuilder
1212
{
1313
/// <summary>
14-
///
14+
/// Gets the <see cref="IServiceCollection"/>.
1515
/// </summary>
1616
public IServiceCollection Services { get; }
1717
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using Microsoft.AspNetCore.Components.Endpoints;
5+
46
namespace Microsoft.Extensions.DependencyInjection;
57

68
/// <summary>
79
/// A builder that can be used to configure Server-Side Blazor.
810
/// </summary>
9-
public interface IServerSideBlazorBuilder
11+
public interface IServerSideBlazorBuilder : IRazorComponentsBuilder
1012
{
1113
/// <summary>
1214
/// Gets the <see cref="IServiceCollection"/>.
1315
/// </summary>
14-
IServiceCollection Services { get; }
16+
public new IServiceCollection Services { get; }
17+
18+
IServiceCollection IRazorComponentsBuilder.Services => Services;
1519
}

src/Components/Server/src/DependencyInjection/RazorComponentsBuilderExtensions.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@ public static class RazorComponentsBuilderExtensions
2525
/// <param name="configure">A callback to configure <see cref="CircuitOptions"/>.</param>
2626
/// <returns>An <see cref="IRazorComponentsBuilder"/> that can be used to further customize the configuration.</returns>
2727
[RequiresUnreferencedCode("Server-side Blazor does not currently support native AOT.", Url = "https://aka.ms/aspnet/nativeaot")]
28-
public static IRazorComponentsBuilder AddServerComponents(this IRazorComponentsBuilder builder, Action<CircuitOptions>? configure = null)
28+
public static IServerSideBlazorBuilder AddServerComponents(this IRazorComponentsBuilder builder, Action<CircuitOptions>? configure = null)
2929
{
3030
ArgumentNullException.ThrowIfNull(builder, nameof(builder));
3131

3232
builder.Services.AddServerSideBlazor(configure);
3333
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<RenderModeEndpointProvider, CircuitEndpointProvider>());
3434

35-
return builder;
35+
return new DefaultServerSideBlazorBuilder(builder.Services);
36+
}
37+
38+
private sealed class DefaultServerSideBlazorBuilder : IServerSideBlazorBuilder
39+
{
40+
public DefaultServerSideBlazorBuilder(IServiceCollection services)
41+
{
42+
Services = services;
43+
}
44+
45+
public IServiceCollection Services { get; }
3646
}
3747

3848
private class CircuitEndpointProvider : RenderModeEndpointProvider

src/Components/Server/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
Microsoft.AspNetCore.Components.Server.Circuits.CircuitInboundActivityContext
33
Microsoft.AspNetCore.Components.Server.Circuits.CircuitInboundActivityContext.Circuit.get -> Microsoft.AspNetCore.Components.Server.Circuits.Circuit!
44
Microsoft.Extensions.DependencyInjection.RazorComponentsBuilderExtensions
5-
static Microsoft.Extensions.DependencyInjection.RazorComponentsBuilderExtensions.AddServerComponents(this Microsoft.AspNetCore.Components.Endpoints.IRazorComponentsBuilder! builder, System.Action<Microsoft.AspNetCore.Components.Server.CircuitOptions!>? configure = null) -> Microsoft.AspNetCore.Components.Endpoints.IRazorComponentsBuilder!
5+
static Microsoft.Extensions.DependencyInjection.RazorComponentsBuilderExtensions.AddServerComponents(this Microsoft.AspNetCore.Components.Endpoints.IRazorComponentsBuilder! builder, System.Action<Microsoft.AspNetCore.Components.Server.CircuitOptions!>? configure = null) -> Microsoft.Extensions.DependencyInjection.IServerSideBlazorBuilder!
66
virtual Microsoft.AspNetCore.Components.Server.Circuits.CircuitHandler.CreateInboundActivityHandler(System.Func<Microsoft.AspNetCore.Components.Server.Circuits.CircuitInboundActivityContext!, System.Threading.Tasks.Task!>! next) -> System.Func<Microsoft.AspNetCore.Components.Server.Circuits.CircuitInboundActivityContext!, System.Threading.Tasks.Task!>!

0 commit comments

Comments
 (0)