PandaTech.BaseConverter 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PandaTech.BaseConverter --version 2.0.1
NuGet\Install-Package PandaTech.BaseConverter -Version 2.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="PandaTech.BaseConverter" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PandaTech.BaseConverter --version 2.0.1
#r "nuget: PandaTech.BaseConverter, 2.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 PandaTech.BaseConverter as a Cake Addin
#addin nuget:?package=PandaTech.BaseConverter&version=2.0.1

// Install PandaTech.BaseConverter as a Cake Tool
#tool nuget:?package=PandaTech.BaseConverter&version=2.0.1

Base Converter

This project provides a class called PandaBaseConverter that can convert a number from base 10 to base 36 and vice versa. This project is available as a NuGet package as well.

Usage

Base 10 to Base 36

To convert a number from base 10 to base 36, call the Base10ToBase36 method, passing in the number as a long

long number = 12345;
string base36Number = BaseConverter.Base10ToBase36(number);

The resulting base36Number will be a string representation of the number in base 36.

Base 36 to Base 10

To convert a number from base 36 to base 10, call the Base36ToBase10 method, passing in the number as a string:

string base36Number = "2n9";
long number = BaseConverter.Base36ToBase10(base36Number);

The resulting number will be the decimal representation of the number in base 36.

Using in DTOs

public class MyDto
{
    [JsonConverter(typeof(PandaJsonBaseConverter))]
    public long Id { get; set; }
}

Using in controllers

[HttpGet("{id}")]
public async Task<ActionResult<MyDto>> Get([PandaParameterBaseConverter] long id)
{
    var myDto = await _myService.Get(id);
    return Ok(myDto);
}

In this case we will work in code with Id as long, but in json it will be as base 36 string.

Configuration

By default, the PandaBaseConverter class uses the characters "0123456789abcdefghijklmnopqrstuvwxyz" for base 36 conversion. You can configure the character set used by setting the *BASE36_CHARS environment variable to a string containing the desired characters.

export BASE36_CHARS="A32145789U0BCDEFGHIJKLMNOPQRSTVWXYZ6"

The resulting number will be the decimal representation of the number in base 36.

Error Handling

If the input to either conversion method is invalid, an ArgumentException will be thrown with an appropriate error message. The message will also be printed to the console.

Prgram.cs

to use PandaParameterBaseConverter in swagger, add the following code to Program.cs


builder.Services.AddSwaggerGen(
    options => 
        options.ParameterFilter<PandaParameterBaseConverter>()
    );
    
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on PandaTech.BaseConverter:

Package Downloads
PandaTech.IEnumerableFilters

This NuGet helps with filtering tables.

Pandatech.EFCoreQueryMagic

Unlock the full potential of your Entity Framework Core applications with Pandatech.EFCoreQueryMagic. This innovative package empowers developers to seamlessly create dynamic, complex queries and filters for SQL tables without diving deep into the intricacies of LINQ or manual query construction. Designed to enhance productivity and maintainability, EFCoreQueryMagic automates the translation of front-end filter requests into optimized, ready-to-execute EF Core queries. Embrace the magic of streamlined data retrieval and manipulation, and elevate your applications to new heights of efficiency and performance.

PandaTech.FileExporter

Export table data into xls, xlsx, csv, pdf formats

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.4 87 4/25/2024
3.0.3 343 3/20/2024
3.0.1 136 3/13/2024
3.0.0 90 3/13/2024
2.0.2 369 12/2/2023
2.0.1 101 11/29/2023
1.0.18 149 11/8/2023
1.0.17 82 11/8/2023
1.0.16 168 11/7/2023
1.0.15 79 11/6/2023
1.0.14 77 11/6/2023
1.0.12 221 10/23/2023
1.0.11 181 7/19/2023
1.0.10 132 7/18/2023
1.0.9 122 7/18/2023
1.0.8 122 7/17/2023
1.0.7 163 6/7/2023
1.0.6 126 6/7/2023
1.0.5 139 6/6/2023
1.0.4 123 6/6/2023
1.0.1 148 5/30/2023
1.0.0 194 4/13/2023

.net 8.0 update and restructure