Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CountryCodeToFlagAndName.cs
1using System.Globalization;
3
5{
9 [AcceptEmptyServiceProvider]
10 public class CountryCodeToFlagAndName : IValueConverter, IMarkupExtension
11 {
13 public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
14 {
15 if (value is string Code && ISO_3166_1.TryGetCountryByCode(Code, out ISO_3166_Country? Country) && Country is not null)
16 return Country.EmojiInfo.Unicode + "\t" + Country.Name;
17 else
18 return value ?? string.Empty;
19 }
20
22 public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
23 {
24 return value;
25 }
26
28 public object ProvideValue(System.IServiceProvider serviceProvider)
29 {
30 return this;
31 }
32 }
33}
Conversion between Country Names and ISO-3166-1 country codes.
Definition: ISO_3166_1.cs:10
static bool TryGetCountryByCode(string? CountryCode, [NotNullWhen(true)] out ISO_3166_Country? Country)
Tries to get the country, given its country code.
Definition: ISO_3166_1.cs:71
Converts a country code to a country flag and name.
object ProvideValue(System.IServiceProvider serviceProvider)
object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
class ISO_3166_Country(string Name, string Alpha2, string Alpha3, int NumericCode, string DialCode, EmojiInfo? EmojiInfo=null)
Representation of an ISO3166-1 Country