Skip to content

Commit

Permalink
expose the original map
Browse files Browse the repository at this point in the history
aspriddell committed May 22, 2024
1 parent 02a2fe6 commit bea455b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions DragonFruit.OnionFruit.Web.Worker/CountryMap.cs
Original file line number Diff line number Diff line change
@@ -28,20 +28,20 @@ static CountryMap()
/// <summary>
/// The mapping of country codes to country names
/// </summary>
[JsonInclude, JsonPropertyName("countries")]
private IReadOnlyDictionary<string, string> CodeMap { get; set; }
[JsonPropertyName("countries")]
public IReadOnlyDictionary<string, string> SourceMap { get; set; }

/// <summary>
/// Gets the country name associated with the provided <see cref="code"/>, or <c>null</c> if not found.
/// </summary>
public string GetCountryName(string code) => CodeMap.GetValueOrDefault(code.ToUpperInvariant());
public string GetCountryName(string code) => SourceMap.GetValueOrDefault(code.ToUpperInvariant());

void IJsonOnDeserialized.OnDeserialized()
{
// convert the dictionary to a frozen dictionary if it's not already
if (CodeMap.GetType().GetGenericTypeDefinition() != typeof(FrozenDictionary<,>))
if (SourceMap.GetType().GetGenericTypeDefinition() != typeof(FrozenDictionary<,>))
{
CodeMap = CodeMap.ToFrozenDictionary();
SourceMap = SourceMap.ToFrozenDictionary();
}
}
}

0 comments on commit bea455b

Please sign in to comment.