Skip to content

Commit b67efab

Browse files
authored
Configuration formatter. (#5)
1 parent 280b569 commit b67efab

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/TinyToolBox.Configuration/Keys/ConfigurationDictionary.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ public ConfigurationDictionary(IEnumerable<KeyValuePair<ConfigurationKey, IConfi
1515

1616
public IReadOnlyList<ConfigurationKey> GetChildKeys(ConfigurationKey parent)
1717
{
18-
var hashSet = new HashSet<ConfigurationKey>(ChildrenOf(parent));
1918
#if NET7_0_OR_GREATER
20-
var list = hashSet.Order(ConfigurationKey.Comparer).ToList();
19+
return ChildrenOf(parent)
20+
.ToHashSet()
21+
.Order(ConfigurationKey.Comparer)
22+
.ToList();
2123
#else
24+
var hashSet = new HashSet<ConfigurationKey>(ChildrenOf(parent));
2225
var list = hashSet.ToList();
2326
list.Sort(ConfigurationKey.Comparer);
24-
#endif
25-
2627
return list;
28+
#endif
2729
}
2830

2931
private IEnumerable<ConfigurationKey> ChildrenOf(ConfigurationKey parent)

src/TinyToolBox.Configuration/Providers/ConfigurationFormatter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private string FormatChained(ConfigurationKey key, ChainedConfigurationProvider
7272
string? result = default;
7373
if (_mappings.TryGetValue(provider.GetType(), out var formatter))
7474
{
75-
result = formatter(provider);
75+
result = formatter.Invoke(provider);
7676
}
7777

7878
if (string.IsNullOrEmpty(result))

0 commit comments

Comments
 (0)