@@ -23,7 +23,7 @@ namespace Asp.Versioning.ApiExplorer;
23
23
[ CLSCompliant ( false ) ]
24
24
public class PartialODataDescriptionProvider : IApiDescriptionProvider
25
25
{
26
- private static int ? beforeOData ;
26
+ private static readonly int BeforeOData = ODataOrder ( ) + 10 ;
27
27
private readonly IOptionsFactory < ODataOptions > odataOptionsFactory ;
28
28
private readonly IOptions < ODataApiExplorerOptions > options ;
29
29
private bool markedAdHoc ;
@@ -42,8 +42,6 @@ public PartialODataDescriptionProvider(
42
42
{
43
43
this . odataOptionsFactory = odataOptionsFactory ?? throw new ArgumentNullException ( nameof ( odataOptionsFactory ) ) ;
44
44
this . options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
45
- beforeOData ??= ODataOrder ( odataOptionsFactory , options ) + 10 ;
46
- Order = beforeOData . Value ;
47
45
}
48
46
49
47
/// <summary>
@@ -84,7 +82,7 @@ protected ODataApiExplorerOptions Options
84
82
/// Gets or sets the order precedence of the current API description provider.
85
83
/// </summary>
86
84
/// <value>The order precedence of the current API description provider.</value>
87
- public int Order { get ; protected set ; }
85
+ public int Order { get ; protected set ; } = BeforeOData ;
88
86
89
87
/// <inheritdoc />
90
88
public virtual void OnProvidersExecuting ( ApiDescriptionProviderContext context )
@@ -107,9 +105,9 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
107
105
{
108
106
var model = models [ i ] ;
109
107
var version = model . GetApiVersion ( ) ;
110
- var options = odataOptionsFactory . Create ( Opts . DefaultName ) ;
108
+ var odata = odataOptionsFactory . Create ( Opts . DefaultName ) ;
111
109
112
- options . AddRouteComponents ( model ) ;
110
+ odata . AddRouteComponents ( model ) ;
113
111
114
112
for ( var j = 0 ; j < results . Count ; j ++ )
115
113
{
@@ -149,12 +147,14 @@ public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
149
147
}
150
148
151
149
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
152
- private static int ODataOrder ( IOptionsFactory < ODataOptions > factory , IOptions < ODataApiExplorerOptions > options ) =>
150
+ private static int ODataOrder ( ) =>
153
151
new ODataApiDescriptionProvider (
154
152
new StubModelMetadataProvider ( ) ,
155
153
new StubModelTypeBuilder ( ) ,
156
- factory ,
157
- options ) . Order ;
154
+ new OptionsFactory < ODataOptions > (
155
+ Enumerable . Empty < IConfigureOptions < ODataOptions > > ( ) ,
156
+ Enumerable . Empty < IPostConfigureOptions < ODataOptions > > ( ) ) ,
157
+ Opts . Create ( new ODataApiExplorerOptions ( ) ) ) . Order ;
158
158
159
159
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
160
160
private static void MarkAsAdHoc ( ODataModelBuilder builder , IEdmModel model ) =>
0 commit comments