Skip to content

Commit e7360de

Browse files
authored
Don't throw when config section is not present (#31)
* Fix bug * Update flow
1 parent cadbee0 commit e7360de

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/Bindicate/Bindicate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageTags>di, ioc, service, collection, extensions, attribute</PackageTags>
1414
<PackageReleaseNotes>Add support for Decorators</PackageReleaseNotes>
1515
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
16-
<Version>1.7.0</Version>
16+
<Version>1.7.1</Version>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

src/Bindicate/Configuration/AutowiringBuilder.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ public AutowiringBuilder WithOptions(IConfiguration configuration)
136136
{
137137
var configSection = configuration.GetSection(attr.ConfigurationSection);
138138

139-
if (!configSection.Exists())
140-
throw new InvalidOperationException($"Missing configuration section: {attr.ConfigurationSection}");
141-
142-
var genericOptionsConfigureMethod = typeof(OptionsConfigurationServiceCollectionExtensions)
143-
.GetMethods()
144-
.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);
145144

146-
var specializedMethod = genericOptionsConfigureMethod.MakeGenericMethod(type);
147-
specializedMethod.Invoke(null, new object[] { _services, configSection });
145+
var specializedMethod = genericOptionsConfigureMethod.MakeGenericMethod(type);
146+
specializedMethod.Invoke(null, new object[] { _services, configSection });
147+
}
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)