UNLowCoder.SourceGen
0.0.3
dotnet add package UNLowCoder.SourceGen --version 0.0.3
NuGet\Install-Package UNLowCoder.SourceGen -Version 0.0.3
<PackageReference Include="UNLowCoder.SourceGen" Version="0.0.3" />
paket add UNLowCoder.SourceGen --version 0.0.3
#r "nuget: UNLowCoder.SourceGen, 0.0.3"
// Install UNLowCoder.SourceGen as a Cake Addin #addin nuget:?package=UNLowCoder.SourceGen&version=0.0.3 // Install UNLowCoder.SourceGen as a Cake Tool #tool nuget:?package=UNLowCoder.SourceGen&version=0.0.3
UnLowCoder.SourceGen
Simple package to generate UNLocode classes from official unece csv zip package. The zip file can be downloaded from here or use this direct link
This package is a source generator that generates classes for the UNLocode csv files. The generated classes are readonly and can be used to access the data in the csv files. For parsing this package uses the UNLowCoder.Core package.
Implemented via C# source generators
Also this package is used by UNLowCoder.Lib that provides the generated classes for the UNLocode csv files.
Usage
Install the nuget package
Add a Nuget package reference to the project file in the project you want to generate unlocodes in:<br>
<PackageReference Include="UNLowCoder.SourceGen" Version="<version>" />
Add the downloaded unlocodes csv zip file to your project
You should rename the zip file to the class name you want to generate. For example UNLOCODE.zip
creates the classes UNLOCODE
.<br>
In an ItemGroup
in your csproj file add an AdditionFiles
element for each unlocode zip file you want to generate classes for
Set the Include
attribute to the path of the file.
Example:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<AdditionalFiles Include="UnLocodes.zip" />
</ItemGroup>
</Project>
You can then use the generated classes in your code like this.
var all_countries = UnLocodes.Countries.All;
var current = UnLocodes.Countries.Get(CultureInfo.CurrentCulture);
var germanLocations = UnLocodes.Locations.DE.All;
var location_HAM_ = UnLocodes.Locations.DE.HAM;
var allLocations = UnLocodes.Locations.All;
var allDivisions = UnLocodes.Subdivisions.All;
var division_german_hh = UnLocodes.Subdivisions.DE.DE_HH;
For sure you can also parse another csv zip file at runtime.
var all = UnLocodeParser.ParseZipArchive("C:\Directory\loc241csv.zip");
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- UNLowCoder.Core (>= 0.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.