File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/Http/Routing/src/Builder Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ namespace Microsoft.AspNetCore.Builder
11
11
/// </summary>
12
12
public sealed class RouteHandlerBuilder : IEndpointConventionBuilder
13
13
{
14
- private readonly IEnumerable < IEndpointConventionBuilder > _endpointConventionBuilders ;
14
+ private readonly IEnumerable < IEndpointConventionBuilder > ? _endpointConventionBuilders ;
15
+ private readonly IEndpointConventionBuilder ? _endpointConventionBuilder ;
15
16
16
17
/// <summary>
17
18
/// Instantiates a new <see cref="RouteHandlerBuilder" /> given a single
@@ -20,7 +21,7 @@ public sealed class RouteHandlerBuilder : IEndpointConventionBuilder
20
21
/// <param name="endpointConventionBuilder">The <see cref="IEndpointConventionBuilder" /> to instantiate with.</param>
21
22
internal RouteHandlerBuilder ( IEndpointConventionBuilder endpointConventionBuilder )
22
23
{
23
- _endpointConventionBuilders = new List < IEndpointConventionBuilder > ( ) { endpointConventionBuilder } ;
24
+ _endpointConventionBuilder = endpointConventionBuilder ;
24
25
}
25
26
26
27
/// <summary>
@@ -39,9 +40,16 @@ public RouteHandlerBuilder(IEnumerable<IEndpointConventionBuilder> endpointConve
39
40
/// <param name="convention">The convention to add to the builder.</param>
40
41
public void Add ( Action < EndpointBuilder > convention )
41
42
{
42
- foreach ( var endpointConventionBuilder in _endpointConventionBuilders )
43
+ if ( _endpointConventionBuilder != null )
43
44
{
44
- endpointConventionBuilder . Add ( convention ) ;
45
+ _endpointConventionBuilder . Add ( convention ) ;
46
+ }
47
+ else
48
+ {
49
+ foreach ( var endpointConventionBuilder in _endpointConventionBuilders ! )
50
+ {
51
+ endpointConventionBuilder . Add ( convention ) ;
52
+ }
45
53
}
46
54
}
47
55
}
You can’t perform that action at this time.
0 commit comments