██ ██ ██████ ██████ ██ ██████ ███ ██ ███████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ █ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ██████ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███ ██████ ██ ██ ███████ ██████ ██ ██ ████ ███████ ██
===============================================================================
A simple package designed to:
- Retrieve a list of all countries.
- Fetch specific details about a country using its identifier.
-
Get All Countries:
- Retrieve a read-only list of all available countries, including their names and capitals.
-
Get Country by ID:
- Fetch detailed information about a specific country using its unique ID.
-
Custom Exception Handling:
- Throws a
CountryNotFoundException
when an invalid country ID is queried.
- Throws a
-
Thread-Safe Initialization:
- Ensures lazy and thread-safe initialization of country data.
Here’s how you can use the package to display all countries and details of Afghanistan:
using World.Net;
using World.Net.Helpers;
Console.WriteLine("All Countries:");
var countries = CountryProvider.GetAllCountries();
foreach (var country in countries)
{
Console.WriteLine($"Name: {country.Name}, Capital: {country.Capital}");
}
Console.WriteLine("\nDetails for Afghanistan:");
var afghanistan = CountryProvider.GetCountry(CountryIdentifier.AfghanistanId);
Console.WriteLine($"Official Name: {afghanistan.OfficialName}, Capital: {afghanistan.Capital}");