Skip to content

Commit f821cc4

Browse files
committed
Update flow
1 parent ef82a19 commit f821cc4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Bindicate/Configuration/AutowiringBuilder.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)