Loken.Utilities
0.5.1
dotnet add package Loken.Utilities --version 0.5.1
NuGet\Install-Package Loken.Utilities -Version 0.5.1
<PackageReference Include="Loken.Utilities" Version="0.5.1" />
<PackageVersion Include="Loken.Utilities" Version="0.5.1" />
<PackageReference Include="Loken.Utilities" />
paket add Loken.Utilities --version 0.5.1
#r "nuget: Loken.Utilities, 0.5.1"
#:package Loken.Utilities@0.5.1
#addin nuget:?package=Loken.Utilities&version=0.5.1
#tool nuget:?package=Loken.Utilities&version=0.5.1
Loken.Utilities
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
MultiMapis aDictionary<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
MultiMapclass provides.Render()and.Parse()methods which can act as serializers and takes some optional settings to control separators.We use
Convert.ChangeTypeand.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
.envand.env.<EnvironmentName>files.Given an env-file with the following content:
STUFF=stuffer THING=thingyCalling 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 | Versions 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. |
-
net8.0
- Loken.Extensions.System (>= 0.5.1)
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.