Replies: 1 comment
-
Closing as duplicate of #1301 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I'm currently working on a project utilizing units.net and have encountered an issue while handling custom units. I've defined a new custom unit called
GasFlowRate
and created two specific measures within it:StandardCubicMetersPerDay
andThousandStandardCubicFeetPerDay
.I've used
UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation
to set the default abbreviations for these units, and they seem to be mapped correctly.However, when I attempt to retrieve the abbreviation for these units using
UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
, I encounter the following error:InnerException: null, Message: "No abbreviation is specified for Enum.ThousandStandardCubicFeetPerDay"
.Interestingly, if I specify the unit directly, like
UnitAbbreviationsCache.Default.GetDefaultAbbreviation(GasFlowRateUnit.StandardCubicMetersPerDay),
it retrieves the abbreviation without any issue.But when I send the unit as a parameter to a function, e.g.,
GetAbbreviation(quantity, GasFlowRateUnit.StandardCubicMetersPerDay)
, it throws the aforementioned error.I've made sure that the unit is being passed correctly, and the enumeration value seems to be in the right format. I've attempted to cast the enum to its specific type and used various methods to handle it, but the issue persists.
Here's a snippet of the relevant code:
Is there something specific I need to be aware of when working with custom units and abbreviations in units.net? Any insights or suggestions on how to resolve this issue would be greatly appreciated.
Thank you in advance for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions