Loken.Utilities 0.5.1

dotnet add package Loken.Utilities --version 0.5.1
                    
NuGet\Install-Package Loken.Utilities -Version 0.5.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="Loken.Utilities" Version="0.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Loken.Utilities" Version="0.5.1" />
                    
Directory.Packages.props
<PackageReference Include="Loken.Utilities" />
                    
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 Loken.Utilities --version 0.5.1
                    
#r "nuget: Loken.Utilities, 0.5.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.
#:package Loken.Utilities@0.5.1
                    
#: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=Loken.Utilities&version=0.5.1
                    
Install as a Cake Addin
#tool nuget:?package=Loken.Utilities&version=0.5.1
                    
Install as a Cake Tool

Loken.Utilities

Nuget

Low level utility classes.

Getting started

Install the package from nuget.org into your .NET 7 or later project using your package manager of choice, or the command line;

dotnet add package Loken.Utilities

Features

A non-exhaustive list of features by namespace.

Loken.Utilities.Collections

  • MultiMap data structure for one-to-many relationships.

    A MultiMap is a Dictionary<T, ISet<T>> where each key maps to multiple values of the same type and provides convenience methods for managing multiple values per key.

    The MultiMap class provides .Render() and .Parse() methods which can act as serializers and takes some optional settings to control separators.

    We use Convert.ChangeType and .ToString() for conversions.

    // Creating a MultiMap explicitly
    var map = new MultiMap<int>();
    map.Add(1, 11);
    map.Add(1, 12);
    map.Add(11, 111);
    map.Add(11, 112);
    map.Add(2, 21);
    map.Add(21, 212);
    
    // Creating an equivalent MultiMap from a string
    const string input = """
    1:11,12
    11:111,112
    2:21
    21:212
    """;
    
    MultiMap<int> parsedMap = MultiMap.Parse<int>(input);
    
    // Rendering the MultiMap back to a string.
    string output = MultiMap.Render(map);
    //     output = input;
    
  • Interchangeable data structure for queues and stacks

    ILinear<string> strings = useQueue ? new LinearQueue<string>() : new LinearStack<string>();
    strings.Attach("A", "B");
    var one = strings.Detach();
    var two = strings.Detach();
    // Content of one and two depends on useQueue.
    

Loken.Utilities.ComponentModel

Our DelimitedStringTypeConverter allow you to convert a delimited string into an array of strings.

This is useful when you want to convert a string like "one;other" into an array of strings ["one", "other"].

var attribute = new TypeConverterAttribute(typeof(DelimitedStringTypeConverter));
TypeDescriptor.AddAttributes(typeof(ICollection<string>), attribute);

string[] arr = "one;other".Convert<string[]>();
//       arr = ["one", "other"];

Loken.Utilities.IO

  • Read environment variables from .env and .env.<EnvironmentName> files.

    Given an env-file with the following content:

    STUFF=stuffer
    THING=thingy
    

    Calling load will add the two environment variables.

    DotEnv.Load();
    

    The file can be in any ancestry folder, and you can optionally specify a different directory than the current directory or even a different file name.

Feedback & Contribution

If you like what you see so far or would like to suggest changes to improve or extend what the library does, please don't hesitate to leave a comment in an issue or even a PR.

You can run the tests by cloning the repo, restoring packages, compiling and running the tests. There is no magic. There is a visual studio solution if you also like that.

The repository contains projects for other packages as well.

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Loken.Utilities:

Package Downloads
Loken.Hierarchies

.NET library for working with hierarchies of identifiers and identifiable objects.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.1 255 8/25/2025
0.5.0 169 7/4/2025