File tree 1 file changed +34
-0
lines changed
src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) .NET Foundation and contributors. All rights reserved.
2
+
3
+ namespace Asp . Versioning . ApiExplorer ;
4
+
5
+ using Microsoft . AspNetCore . Http ;
6
+ using Microsoft . AspNetCore . Routing ;
7
+ using Microsoft . Extensions . Primitives ;
8
+
9
+ /// <summary>
10
+ /// Provides extension methods for <see cref="IApiVersionDescriptionProviderFactory"/>.
11
+ /// </summary>
12
+ [ CLSCompliant ( false ) ]
13
+ public static class IApiVersionDescriptionProviderFactoryExtensions
14
+ {
15
+ /// <summary>
16
+ /// Creates and returns an API version description provider.
17
+ /// </summary>
18
+ /// <param name="factory">The extended <see cref="IApiVersionDescriptionProviderFactory"/>.</param>
19
+ /// <returns>A new <see cref="IApiVersionDescriptionProvider">API version description provider</see>.</returns>
20
+ public static IApiVersionDescriptionProvider Create ( this IApiVersionDescriptionProviderFactory factory )
21
+ {
22
+ ArgumentNullException . ThrowIfNull ( factory ) ;
23
+ return factory . Create ( new EmptyEndpointDataSource ( ) ) ;
24
+ }
25
+
26
+ private sealed class EmptyEndpointDataSource : EndpointDataSource
27
+ {
28
+ public override IReadOnlyList < Endpoint > Endpoints { get ; } = [ ] ;
29
+
30
+ public override IChangeToken GetChangeToken ( ) => new CancellationChangeToken ( CancellationToken . None ) ;
31
+
32
+ public override IReadOnlyList < Endpoint > GetGroupedEndpoints ( RouteGroupContext context ) => Endpoints ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments