UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Map and look up unit abbreviations by strings instead of enums

Open angularsen opened this issue 2 years ago • 1 comments

Blocks #1181

QuantityType enum is already deprecated and will be removed in #982 in order to better support third-party quantities and units.

The same could be done for the 100+ unit enums, like LengthUnit

Instead of

string abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unitInfo.GetType(), (int)unitInfo);

We could support, without breaking change:

string abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation("Length", "Millimeter");

Optionally, we could deprecate the enum-based overloads and remove them in #982 or future major version bump.

Related to discussion: https://github.com/angularsen/UnitsNet/issues/1062#issuecomment-1073219229

angularsen avatar Mar 20 '22 10:03 angularsen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 05:08 stale[bot]