Skip to content

Commit c8f5160

Browse files
Fixed issue with the json configuration not recognizing an expiry param for the caching provider element
1 parent 36e7740 commit c8f5160

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/DotNetToolkit.Repository/Internal/ConfigFile/Json/ConfigurationSection.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ internal class ConfigurationSection : ConfigFile.IConfigurationSection
2626
private const string DefaultContextFactorySectionKey = "defaultContextFactory";
2727
private const string LoggingProviderSectionKey = "loggingProvider";
2828
private const string CachingProviderSectionKey = "cachingProvider";
29-
private const string MappingProviderSectionKey = "mappingProvider";
3029
private const string InterceptorCollectionSectionKey = "interceptors";
3130
private const string ParameterCollectionSectionKey = "parameters";
3231
private const string TypeKey = "type";
32+
private const string ExpiryKey = "expiry";
3333

3434
private readonly IConfigurationSection _root;
3535

@@ -77,6 +77,12 @@ public ICacheProvider GetCachingProvider()
7777
if (section != null)
7878
{
7979
var value = GetTypedValue<ICacheProvider>(section);
80+
var expiry = ExtractExpiry(section);
81+
82+
if (expiry != null)
83+
{
84+
value.Expiry = expiry;
85+
}
8086

8187
return value;
8288
}
@@ -138,6 +144,20 @@ private static Type ExtractType([NotNull] IConfigurationSection section, bool is
138144
return Type.GetType(value, throwOnError: true);
139145
}
140146

147+
private static TimeSpan? ExtractExpiry([NotNull] IConfigurationSection section)
148+
{
149+
Guard.NotNull(section, nameof(section));
150+
151+
var keyValues = ExtractParameters(section);
152+
153+
if (keyValues.ContainsKey(ExpiryKey))
154+
{
155+
return TimeSpan.Parse(keyValues[ExpiryKey]);
156+
}
157+
158+
return null;
159+
}
160+
141161
private static KeyValuePair<string, string> ExtractKeyValue([NotNull] IConfigurationSection section)
142162
{
143163
Guard.NotNull(section, nameof(section));

0 commit comments

Comments
 (0)