BidirectionalMap 1.0.0

dotnet add package BidirectionalMap --version 1.0.0                
NuGet\Install-Package BidirectionalMap -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="BidirectionalMap" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BidirectionalMap --version 1.0.0                
#r "nuget: BidirectionalMap, 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.
// Install BidirectionalMap as a Cake Addin
#addin nuget:?package=BidirectionalMap&version=1.0.0

// Install BidirectionalMap as a Cake Tool
#tool nuget:?package=BidirectionalMap&version=1.0.0                

Bidirectional Map

.NET Core

Exactly what it sounds like. This library offers a single class BiMap that let's you define a two-way one-to-one map between values the same way you would define a one-way map with a dictionary.

Example:

using BidirectionalMap;

BiMap<int, string> map = new BiMap<int, string>(){
	{1, "Circle"},
	{2, "Triangle"},
	{3, "Square"},
};

var mappedString = map.Forward[1]; //"Circle"
var mappedInt = map.Reverse["Circle"]; // 1

It isn't limited to value types

BiMap<int, Action> map = new BiMap<int, string>(){
	{1, () => /* do something*/},
};

var action = map.Forward[1]; 

Why?

Well, table-driven value mapping is a very powerfull technique that makes conversions more readable, easier to update, and easier to load from non-code sources.
Some common scenarios for this kind of technique include

  • Mapping to some kind of storage (say, converting between enum and string)
  • Mapping display values to and from requests
  • Wrapping other code (adapter-style) to consume the api on your own terms
  • Choosing an action or configuration based on some kind of type value (this is usually just one-way though)

Install

Will be available as a nuget package... pending upload

Feedback/Bugs/Contribution

Feel free to open an issue to start the conversation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 BidirectionalMap:

Package Downloads
Crash.Plugins

SDK for creating Crash Plugins

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 99,701 4/24/2020