ββ ββ ββββββ ββββββ ββ ββββββ βββ ββ βββββββ ββββββββ ββ ββ ββ ββ ββ ββ ββ ββ ββ βββββ ββ ββ ββ ββ β ββ ββ ββ ββββββ ββ ββ ββ ββ ββ ββ ββββββ ββ ββ βββ ββ ββ ββ ββ ββ ββ ββ ββ ββ ββ ββ ββ ββ βββ βββ ββββββ ββ ββ βββββββ ββββββ ββ ββ ββββ βββββββ ββ
===============================================================================
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}");