Netizine.Enums.Country 1.0.1

dotnet add package Netizine.Enums.Country --version 1.0.1                
NuGet\Install-Package Netizine.Enums.Country -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Netizine.Enums.Country" Version="1.0.1" />                
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.1                
#r "nuget: Netizine.Enums.Country, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.1

// Install Netizine.Enums.Country as a Cake Tool
#tool nuget:?package=Netizine.Enums.Country&version=1.0.1                

Netizine.Enums.Country

A country enum created to simplify mapping countries to an enum. Created from the country data extracted from Wikipedia.

Provides a few extension methods to easily access country name, description, state name, ISO 3166-1 codes such as the Alpha-2, Alpha-3 and Numeric codes etc as shown 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);
            
            //Validate USA post code
            var usa = Country.UnitedStatesOfAmerica;
            var r = new Regex(usa.GetPostalCodeRegex());
            var postalCodeValid = r.IsMatch("85001");
            var postalCodeInvalid = r.IsMatch("85001A");
        }

        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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 9,232 6/16/2020
1.0.0 413 6/16/2020

Initial Release