diff --git a/sample/CountryData.Sample.Console/Program.cs b/sample/CountryData.Sample.Console/Program.cs index f8793bc..5bc35b3 100644 --- a/sample/CountryData.Sample.Console/Program.cs +++ b/sample/CountryData.Sample.Console/Program.cs @@ -1,167 +1,194 @@ -using CountryData.Standard; + +using CountryData.Standard; -namespace CountryData.Sample.CountryConsoleProject +/// +/// Main program class for demonstrating the use of the CountryData library. +/// +public static class Program { /// - /// Main program class for demonstrating the use of the CountryData library. + /// Static instance of CountryHelper used throughout the program. /// - public static class Program + private static readonly CountryHelper _helper = new CountryHelper(); + + + /// + /// Entry point of the program. + /// + public static void Main() { - /// - /// Static instance of CountryHelper used throughout the program. - /// - private static readonly CountryHelper _helper = new CountryHelper(); - - /// - /// Entry point of the program. - /// - public static void Main() - { - GetCountries(); - GetCountryByCode("US"); - GetCountryData(); - GetRegionsByCountryCode("US"); - GetCountryFlag("US"); - GetPhoneCodeByCountryShortCode("AF"); - GetCountryByPhoneCode("+233"); - GetCurrencyCodesByCountryCode("US"); - GetCountryByCurrencyCode("GHS"); - GetCountryCode("Ghana"); - } + GetCountries(); + GetCountryByCode("US"); + GetCountryData(); + GetRegionsByCountryCode("US"); + GetCountryFlag("US"); + GetPhoneCodeByCountryShortCode("AF"); + GetCountryByPhoneCode("+233"); + GetCurrencyCodesByCountryCode("US"); + GetCountryByCurrencyCode("GHS"); + GetCountryCode("Ghana"); + GetAllCurrencyCodesByCountryCode(); - /// - /// Retrieves a list of all countries and prints them to the console. - /// - private static void GetCountries() - { - var countries = _helper.GetCountries(); - Console.WriteLine("Countries:"); - foreach (var country in countries) - { - Console.WriteLine(country); - } - } - /// - /// Retrieves the data for a given country code and prints it to the console. - /// - /// The ISO country code. - private static void GetCountryByCode(string countryCode) - { - var country = _helper.GetCountryByCode(countryCode); - Console.WriteLine($"Country data for {countryCode}:"); - Console.WriteLine(country.CountryName); - } + } - /// - /// Retrieves comprehensive data for all countries and prints it to the console. - /// - private static void GetCountryData() + /// + /// Retrieves a list of all countries and prints them to the console. + /// + private static void GetCountries() + { + var countries = _helper.GetCountries(); + Console.WriteLine("Countries:"); + foreach (var country in countries) { - var countryData = _helper.GetCountryData(); - Console.WriteLine("Country data:"); - foreach (var data in countryData) - { - Console.WriteLine(data.CountryName); - } + Console.WriteLine(country); } + } - /// - /// Retrieves the regions for a given country code and prints them to the console. - /// - /// The ISO country code. - private static void GetRegionsByCountryCode(string countryCode) - { - var regions = _helper.GetRegionByCountryCode(countryCode); - Console.WriteLine($"Regions for {countryCode}:"); - foreach (var region in regions) - { - Console.WriteLine(region.Name); - } - } + /// + /// Retrieves the data for a given country code and prints it to the console. + /// + /// The ISO country code. + private static void GetCountryByCode(string countryCode) + { + var country = _helper.GetCountryByCode(countryCode); + Console.WriteLine($"Country data for {countryCode}:"); + Console.WriteLine(country.CountryName); + } - /// - /// Retrieves the emoji flag for a given country short code and prints it to the console. - /// - /// The country short code. - private static void GetCountryFlag(string shortCode) + /// + /// Retrieves comprehensive data for all countries and prints it to the console. + /// + private static void GetCountryData() + { + var countryData = _helper.GetCountryData(); + Console.WriteLine("Country data:"); + foreach (var data in countryData) { - var flag = _helper.GetCountryEmojiFlag(shortCode); - Console.WriteLine($"Flag for {shortCode}:"); - Console.WriteLine(flag); + Console.WriteLine(data.CountryName); } + } - /// - /// Retrieves the phone code for a given country short code and prints it to the console. - /// - /// The country short code. - private static void GetPhoneCodeByCountryShortCode(string shortCode) + /// + /// Retrieves the regions for a given country code and prints them to the console. + /// + /// The ISO country code. + private static void GetRegionsByCountryCode(string countryCode) + { + var regions = _helper.GetRegionByCountryCode(countryCode); + Console.WriteLine($"Regions for {countryCode}:"); + foreach (var region in regions) { - var phoneCode = _helper.GetPhoneCodeByCountryShortCode(shortCode); - Console.WriteLine($"Phone code for {shortCode}:"); - Console.WriteLine(phoneCode); + Console.WriteLine(region.Name); } + } - /// - /// Retrieves the country name for a given phone code and prints it to the console. - /// - /// The phone code. - private static void GetCountryByPhoneCode(string phoneCode) + /// + /// Retrieves the emoji flag for a given country short code and prints it to the console. + /// + /// The country short code. + private static void GetCountryFlag(string shortCode) + { + var flag = _helper.GetCountryEmojiFlag(shortCode); + Console.WriteLine($"Flag for {shortCode}:"); + Console.WriteLine(flag); + } + + /// + /// Retrieves the phone code for a given country short code and prints it to the console. + /// + /// The country short code. + private static void GetPhoneCodeByCountryShortCode(string shortCode) + { + var phoneCode = _helper.GetPhoneCodeByCountryShortCode(shortCode); + Console.WriteLine($"Phone code for {shortCode}:"); + Console.WriteLine(phoneCode); + } + + /// + /// Retrieves the country name for a given phone code and prints it to the console. + /// + /// The phone code. + private static void GetCountryByPhoneCode(string phoneCode) + { + var countries = _helper.GetCountryByPhoneCode(phoneCode); + Console.WriteLine($"Country for phone code {phoneCode}:"); + foreach (var country in countries) { - var countries = _helper.GetCountryByPhoneCode(phoneCode); - Console.WriteLine($"Country for phone code {phoneCode}:"); - foreach (var country in countries) - { - Console.WriteLine(country.CountryName); - } + Console.WriteLine(country.CountryName); } + } - /// - /// Retrieves and prints the currency codes for a given country code. - /// - /// The short country code to look up currency codes for. - private static void GetCurrencyCodesByCountryCode(string shortCode) + /// + /// Retrieves and prints the currency codes for a given country code. + /// + /// The short country code to look up currency codes for. + private static void GetCurrencyCodesByCountryCode(string shortCode) + { + var currencyCodes = _helper.GetCurrencyCodesByCountryCode(shortCode); + Console.WriteLine($"Currency codes for {shortCode}:"); + foreach (var currencyCode in currencyCodes) { - var currencyCodes = _helper.GetCurrencyCodesByCountryCode(shortCode); - Console.WriteLine($"Currency codes for {shortCode}:"); - foreach (var currencyCode in currencyCodes) - { - Console.WriteLine(currencyCode.Code); - } + Console.WriteLine(currencyCode.Code); } + } - /// - /// Retrieves and prints the countries that use a given currency code. - /// - /// The currency code to look up countries for. - private static void GetCountryByCurrencyCode(string currencyCode) + /// + /// Retrieves and prints the countries that use a given currency code. + /// + /// The currency code to look up countries for. + private static void GetCountryByCurrencyCode(string currencyCode) + { + var countries = _helper.GetCountryByCurrencyCode(currencyCode); + Console.WriteLine($"Countries for currency code {currencyCode}:"); + foreach (var country in countries) { - var countries = _helper.GetCountryByCurrencyCode(currencyCode); - Console.WriteLine($"Countries for currency code {currencyCode}:"); - foreach (var country in countries) - { - Console.WriteLine(country.CountryName); - } + Console.WriteLine(country.CountryName); } + } + + /// + /// Retrieves the country code for a given country name and prints it to the console. + /// + /// The name of the country. + private static void GetCountryCode(string countryName) + { + using var manager = new CountryExtensions(); + var result = manager.GetCountryCode(countryName); + Console.WriteLine($"Country code for {countryName} is {result} "); + } - /// - /// Retrieves the country code for a given country name and prints it to the console. - /// - /// The name of the country. - private static void GetCountryCode(string countryName) + + /// + /// Prints the currency codes for all countries to the console. + /// + /// The short country code to look up currency codes for. + + public static void GetAllCurrencyCodesByCountryCode() + { + + var countryData = _helper.GetCountryData(); + foreach (var data in countryData) { - using var manager = new CountryExtensions(); - var result = manager.GetCountryCode(countryName); - Console.WriteLine($"Country code for {countryName} is {result} "); - } + var currencyCodes = _helper.GetCurrencyCodesByCountryCode(data.CountryShortCode); + Console.WriteLine($"Currency codes for {data.CountryShortCode}:"); + foreach (var currencyCode in currencyCodes) + { + Console.WriteLine($"{currencyCode.Name}" + $"{currencyCode.Code}"); + } + } } + } + + + diff --git a/src/CountryData.Standard/Currency.cs b/src/CountryData.Standard/Currency.cs index a4b5137..8ffa3d2 100644 --- a/src/CountryData.Standard/Currency.cs +++ b/src/CountryData.Standard/Currency.cs @@ -1,9 +1,8 @@ namespace CountryData.Standard { - public class Currency + public class Currency { - public string Code { get; set; } + public string Code { get; set; } public string Name { get; set; } - } } diff --git a/src/CountryData.Standard/data.json b/src/CountryData.Standard/data.json index c5de668..5dbb2d6 100644 --- a/src/CountryData.Standard/data.json +++ b/src/CountryData.Standard/data.json @@ -756,10 +756,18 @@ } ] }, + { "countryName": "Antarctica", "countryShortCode": "AQ", "phoneCode": "+672", + "currency": [ + { + "code": null, + "name": null + } + ], + "regions": [ { "name": "Antarctica", @@ -767,6 +775,9 @@ } ] }, + + + { "countryName": "Antigua and Barbuda", "countryShortCode": "AG", @@ -2221,8 +2232,8 @@ "phoneCode": "+47", "currency": [ { - "code": "", - "name": "" + "code": "null", + "name": "null" } ], "regions": [ @@ -3019,7 +3030,7 @@ "name": "Quebec", "shortCode": "QC" }, - { + {bo "name": "Saskatchewan", "shortCode": "SK" }, @@ -6284,8 +6295,8 @@ "shortCode": "SD" }, { - "name": "Sud-Est", - "shortCode": "SE" + "name": "AUD", + "name": "Australian dollare": "SE" } ] }, @@ -6295,8 +6306,8 @@ "phoneCode": "+672", "currency": [ { - "code": "", - "name": "" + "code": "null", + "name": " null" } ], "regions": [ @@ -8159,8 +8170,8 @@ { "name": "Tarawa" }, - { - "name": "Teraina" + {KPW", + "name": "North Korean wonTeraina" } ] }, @@ -8170,8 +8181,8 @@ "phoneCode": "+850", "currency": [ { - "code": "", - "name": "" + "code": "null", + "name": "null" } ], "regions": [ @@ -16663,7 +16674,7 @@ "name": "Saramacca", "shortCode": "SA" }, - { + {Eswatini "name": "Sipaliwini", "shortCode": "SI" }, @@ -20555,8 +20566,8 @@ "phoneCode":"+1340", "currency": [ { - "code": "", - "name": "" + "code": "USD", + "name": "United States dollar" } ], "regions": [