Netizine.Enums.Country 1.0.0

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
Install-Package Netizine.Enums.Country -Version 1.0.0
dotnet add package Netizine.Enums.Country --version 1.0.0
<PackageReference Include="Netizine.Enums.Country" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Netizine.Enums.Country --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Netizine.Enums.Country, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Netizine.Enums.Country as a Cake Addin
#addin nuget:?package=Netizine.Enums.Country&version=1.0.0

// Install Netizine.Enums.Country as a Cake Tool
#tool nuget:?package=Netizine.Enums.Country&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Netizine.Enums.Country

A country enum created to simplyfy mapping countries to a enum. Created from the country data exttracted from Wikipedia.

Using Netizine.Enums.Country

To use the country enum in your project, add the Netizine.Enums.Country NuGet package to your project.

Provides a few extension methods to easilly access country name, decription, state name, ISO 3166-1 codes such as the Alpha-2, Alpha-3 and Numeric codes etc as show below. Extension Methods

As a example, calling the following code

var imageUri = countries.First().GetDataURIImage();

Would return data:image/png;base64,iVBO........ which you can use to render a png country flag for the United States of America United States of America

in the case of convert to and from JSOn, i have included a CountryConverter that you can use to try multiple different ways to cast to the correct enum namely country name, country description, the ISO 3166-1 codes etc.

        static void Main(string[] args)
        {
            var countries = ((Country[]) Enum.GetValues(typeof(Country)))
                .Where(countryEnum => countryEnum == Country.UnitedStatesOfAmerica || countryEnum == Country.UnitedKingdom).ToList();
            var json = JsonConvert.SerializeObject(countries, Converter.Settings);
            var newCountries = JsonConvert.DeserializeObject<List<Country>>(json, Converter.Settings);
        }

        public static class Converter
        {
            public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
            {
                MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
                DateParseHandling = DateParseHandling.None,
                Converters =
                {
                    CountryConverter.Singleton,
                    new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
                },
            };
        }
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 966 6/16/2020
1.0.0 225 6/16/2020

Initial Release