File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/Bindicate/Configuration Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -136,12 +136,15 @@ public AutowiringBuilder WithOptions(IConfiguration configuration)
136136 {
137137 var configSection = configuration . GetSection ( attr . ConfigurationSection ) ;
138138
139- var genericOptionsConfigureMethod = typeof ( OptionsConfigurationServiceCollectionExtensions )
140- . GetMethods ( )
141- . FirstOrDefault ( m => m . Name == "Configure" && m . GetParameters ( ) . Length == 2 ) ;
139+ if ( configSection . Exists ( ) )
140+ {
141+ var genericOptionsConfigureMethod = typeof ( OptionsConfigurationServiceCollectionExtensions )
142+ . GetMethods ( )
143+ . FirstOrDefault ( m => m . Name == "Configure" && m . GetParameters ( ) . Length == 2 ) ;
142144
143- var specializedMethod = genericOptionsConfigureMethod . MakeGenericMethod ( type ) ;
144- specializedMethod . Invoke ( null , new object [ ] { _services , configSection } ) ;
145+ var specializedMethod = genericOptionsConfigureMethod . MakeGenericMethod ( type ) ;
146+ specializedMethod . Invoke ( null , new object [ ] { _services , configSection } ) ;
147+ }
145148 }
146149 }
147150 }
You can’t perform that action at this time.
0 commit comments