RepletoryLib.Utilities.Conversion 1.0.0

dotnet add package RepletoryLib.Utilities.Conversion --version 1.0.0
                    
NuGet\Install-Package RepletoryLib.Utilities.Conversion -Version 1.0.0
                    
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="RepletoryLib.Utilities.Conversion" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RepletoryLib.Utilities.Conversion" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RepletoryLib.Utilities.Conversion" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RepletoryLib.Utilities.Conversion --version 1.0.0
                    
#r "nuget: RepletoryLib.Utilities.Conversion, 1.0.0"
                    
#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.
#:package RepletoryLib.Utilities.Conversion@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RepletoryLib.Utilities.Conversion&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RepletoryLib.Utilities.Conversion&version=1.0.0
                    
Install as a Cake Tool

RepletoryLib.Utilities.Conversion

Type conversion utilities for JSON, XML, CSV, Base64, enums, and unit conversions.

Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.

NuGet .NET 10 License: MIT


Overview

RepletoryLib.Utilities.Conversion provides a collection of static converter classes for common data transformation tasks. All converters are static -- no DI registration required.

Key Features

  • JSON -- Serialize/deserialize with pretty-print and safe try-parse
  • XML -- XML serialization and deserialization
  • CSV -- Convert collections to/from CSV strings
  • Base64 -- Encode/decode strings and byte arrays
  • Enum -- Display names, dictionaries, and value listing
  • Type -- Safe generic type conversion with defaults
  • Unit -- Metric/imperial conversions (km/miles, kg/lbs, C/F, liters/gallons)

Installation

dotnet add package RepletoryLib.Utilities.Conversion

Dependencies

Package Type
RepletoryLib.Common RepletoryLib

Usage Examples

JSON

using RepletoryLib.Utilities.Conversion;

var order = new Order { Id = 1, Total = 299.99m };

string json = JsonConverter.Serialize(order);                 // Compact
string pretty = JsonConverter.Serialize(order, pretty: true); // Indented

var restored = JsonConverter.Deserialize<Order>(json);

// Safe parsing
if (JsonConverter.TryDeserialize<Order>(json, out var result))
{
    Console.WriteLine(result!.Total);
}

CSV

using RepletoryLib.Utilities.Conversion;

var products = new List<Product>
{
    new() { Name = "Widget", Price = 9.99m },
    new() { Name = "Gadget", Price = 19.99m }
};

string csv = CsvConverter.ToCsv(products);
// "Name,Price\nWidget,9.99\nGadget,19.99"

var parsed = CsvConverter.FromCsv<Product>(csv);

Base64

using RepletoryLib.Utilities.Conversion;

string encoded = Base64Converter.Encode("Hello World");   // "SGVsbG8gV29ybGQ="
string decoded = Base64Converter.Decode(encoded);         // "Hello World"

byte[] bytes = System.Text.Encoding.UTF8.GetBytes("data");
string b64 = Base64Converter.EncodeBytes(bytes);
byte[] back = Base64Converter.DecodeBytes(b64);

Enum

using RepletoryLib.Utilities.Conversion;
using System.ComponentModel.DataAnnotations;

public enum OrderStatus
{
    [Display(Name = "Pending Payment")]
    Pending,
    [Display(Name = "Order Shipped")]
    Shipped,
    Delivered
}

string display = EnumConverter.ToDisplayName(OrderStatus.Pending); // "Pending Payment"
var status = EnumConverter.FromDisplayName<OrderStatus>("Order Shipped"); // Shipped

var allValues = EnumConverter.GetValues<OrderStatus>();
var dict = EnumConverter.ToDictionary<OrderStatus>();
// { 0: "Pending Payment", 1: "Order Shipped", 2: "Delivered" }

Type Conversion

using RepletoryLib.Utilities.Conversion;

if (TypeConverter.TryConvert<int>("42", out var num))
    Console.WriteLine(num); // 42

decimal price = TypeConverter.ConvertOrDefault<decimal>("invalid", 0m); // 0m

Unit Conversion

using RepletoryLib.Utilities.Conversion;

double miles = UnitConverter.KmToMiles(100);           // 62.137...
double km = UnitConverter.MilesToKm(62.137);           // ~100
double lbs = UnitConverter.KgToLbs(80);                // 176.37...
double fahrenheit = UnitConverter.CelsiusToFahrenheit(37); // 98.6
double gallons = UnitConverter.LitersToGallons(3.785); // ~1.0

API Reference

Class Methods
JsonConverter Serialize<T>, Deserialize<T>, TryDeserialize<T>
XmlConverter Serialize<T>, Deserialize<T>
CsvConverter ToCsv<T>, FromCsv<T>
Base64Converter Encode, Decode, EncodeBytes, DecodeBytes
EnumConverter ToDisplayName<T>, FromDisplayName<T>, GetValues<T>, ToDictionary<T>
TypeConverter TryConvert<T>, ConvertOrDefault<T>
UnitConverter KmToMiles, MilesToKm, KgToLbs, LbsToKg, CelsiusToFahrenheit, FahrenheitToCelsius, LitersToGallons, GallonsToLiters

Integration with Other RepletoryLib Packages

Package Relationship
RepletoryLib.Common Direct dependency
RepletoryLib.Data.Interceptors [JsonSerialize] and [Base64Encode] use similar conversion logic
RepletoryLib.Utilities.Formatting Format converted values for display

License

This project is licensed under the MIT License.

Copyright (c) 2024-2026 Repletory.


For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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.0 79 3/2/2026