Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Tips on Handling Measurements and Units Listing, and Transforming Between Strings and Objects without Reflection #63

Open
CPMOliveira opened this issue Sep 10, 2024 · 1 comment

Comments

@CPMOliveira
Copy link

CPMOliveira commented Sep 10, 2024

Hello,

I’ve recently started using the EngineeringUnits library and have been impressed with its capabilities. However, I’m facing a couple of challenges and would appreciate some guidance:

  1. Listing Available Measurements and Units: Is there a recommended approach or built-in method for easily listing all the available measurements and their corresponding units? I would like to create a comprehensive list for a user interface, but I’m not sure of the most efficient way to achieve this.
  2. Transforming Between Strings and Objects Without Using Reflection: I need to transform strings (representing measurement names or unit symbols) into the corresponding objects in EngineeringUnits, but I’d like to avoid using reflection for performance reasons. Do you have any suggestions or best practices for achieving this transformation efficiently?

Any advice or examples would be highly appreciated.

@MadsKirkFoged
Copy link
Owner

Hi CPMOliveira,

We have a list on the frontpage:
https://github.com/MadsKirkFoged/EngineeringUnits?tab=readme-ov-file#what-units-are-included

This list is generated using this code:
https://github.com/MadsKirkFoged/EngineeringUnits/blob/master/CodeGen/Code/UnitListGenerator.cs

The closest we have right now is this:

//Got from database (Stored in two different cells)
double? value = 10;
string unit = "Meter";

//Put it back together
Length temp = value.AddUnit<LengthUnit>(unit); 

However we dont (yet) have a way to turn fx "10 m/s" in a Speed-object.

If you could come with some examples/User stories of the behavior you want, it might not be that difficult to create

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants