Skip to content

Commit

Permalink
Rename property IsIReadOnlyDictionaryEnabled to IsIReadOnlyDictionary…
Browse files Browse the repository at this point in the history
…Supported
  • Loading branch information
axunonb committed Sep 25, 2023
1 parent 509c990 commit bd39877
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/SmartFormat.Tests/Extensions/DictionarySourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void IReadOnlyDictionary_With_IConvertible_Key()
{
var roDict = new CustomReadOnlyDictionary<IConvertible, object?>(new Dictionary<IConvertible, object?> { { 1, 1 }, { "Two", 2 }, { "Three", "three" }, });
var smart = new SmartFormatter()
.AddExtensions(new DefaultSource(), new DictionarySource { IsIReadOnlyDictionaryEnabled = true })
.AddExtensions(new DefaultSource(), new DictionarySource { IsIReadOnlyDictionarySupported = true })
.AddExtensions(new DefaultFormatter());
var result = smart.Format("{1}{Two}{Three}", roDict);

Expand All @@ -189,7 +189,7 @@ public void IReadOnlyDictionary_With_String_Key()
{
var roDict = new CustomReadOnlyDictionary<string, object?>(new Dictionary<string, object?> { { "One", 1 }, { "Two", 2 }, { "Three", "three" }, });
var smart = new SmartFormatter()
.AddExtensions(new DefaultSource(), new DictionarySource { IsIReadOnlyDictionaryEnabled = true })
.AddExtensions(new DefaultSource(), new DictionarySource { IsIReadOnlyDictionarySupported = true })
.AddExtensions(new DefaultFormatter());
var result = smart.Format("{One}{Two}{Three}", roDict);

Expand All @@ -199,7 +199,7 @@ public void IReadOnlyDictionary_With_String_Key()
[Test]
public void IReadOnlyDictionary_Cache_Should_Store_Types_It_Cannot_Handle()
{
var dictSource = new DictionarySource { IsIReadOnlyDictionaryEnabled = true };
var dictSource = new DictionarySource { IsIReadOnlyDictionarySupported = true };
var kvp = new KeyValuePair<string, object?>("One", 1);
var smart = new SmartFormatter()
.AddExtensions(new DefaultSource(), dictSource, new KeyValuePairSource())
Expand Down
6 changes: 3 additions & 3 deletions src/SmartFormat/Extensions/DictionarySource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SmartFormat.Extensions;
/// and <see cref="IReadOnlyDictionary{TKey,TValue}"/>.
/// Include this source, if any of these types shall be used.
/// <para/>
/// For support of <see cref="IReadOnlyDictionary{TKey,TValue}"/> <see cref="IsIReadOnlyDictionaryEnabled"/> must be set to <see langword="true"/>.
/// For support of <see cref="IReadOnlyDictionary{TKey,TValue}"/> <see cref="IsIReadOnlyDictionarySupported"/> must be set to <see langword="true"/>.
/// This uses Reflection and is slower than the other types despite caching.
/// </summary>
public class DictionarySource : Source
Expand Down Expand Up @@ -59,7 +59,7 @@ public override bool TryEvaluateSelector(ISelectorInfo selectorInfo)
}

// This is for IReadOnlyDictionary<,> using Reflection
if (IsIReadOnlyDictionaryEnabled && TryGetDictionaryValue(current, selector,
if (IsIReadOnlyDictionarySupported && TryGetDictionaryValue(current, selector,
selectorInfo.FormatDetails.Settings.GetCaseSensitivityComparison(), out var value))
{
selectorInfo.Result = value;
Expand Down Expand Up @@ -89,7 +89,7 @@ public override bool TryEvaluateSelector(ISelectorInfo selectorInfo)
/// Although caching is used, this is still slower than the other types.
/// Default is <see langword="false"/>.
/// </summary>
public bool IsIReadOnlyDictionaryEnabled { get; set; } = false;
public bool IsIReadOnlyDictionarySupported { get; set; } = false;

private bool TryGetDictionaryValue(object obj, string key, StringComparison comparison, out object? value)
{
Expand Down

0 comments on commit bd39877

Please sign in to comment.