PandaTech.BaseConverter 1.0.16

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

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

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 net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.3 464 6/21/2024
4.0.2 116 6/20/2024
4.0.1 117 6/19/2024
4.0.0 122 6/18/2024
3.0.6 418 5/8/2024
3.0.5 152 5/6/2024
3.0.4 128 4/25/2024
3.0.3 506 3/20/2024
3.0.1 172 3/13/2024
3.0.0 120 3/13/2024
2.0.2 490 12/2/2023
2.0.1 132 11/29/2023
1.0.18 219 11/8/2023
1.0.17 117 11/8/2023
1.0.16 261 11/7/2023
1.0.15 102 11/6/2023
1.0.14 108 11/6/2023
1.0.12 321 10/23/2023
1.0.11 205 7/19/2023
1.0.10 162 7/18/2023
1.0.9 143 7/18/2023
1.0.8 146 7/17/2023
1.0.7 185 6/7/2023
1.0.6 159 6/7/2023
1.0.5 164 6/6/2023
1.0.4 144 6/6/2023
1.0.1 164 5/30/2023
1.0.0 219 4/13/2023