-
Notifications
You must be signed in to change notification settings - Fork 404
Create a quantity from composed quantities #937
-
Hi all,
I have been reading your samples with a great interest but I am not sure that I could achieve my goals with this lib...
I have a quantity which is described by many values of differents units.
Could you please tell me how can I build the final quantity from all those parts ?
Example:
My volume described as:
- 2 liters
- 9 deciliters
- 3 milliliters
=> the final quantity in liters should be 2,903 L
Thank you
Leny
Beta Was this translation helpful? Give feedback.
All reactions
Hi, there is no direct support for this in the library today.
The best you can accomplish today, is something like Volume.Parse("2 l") + Volume.Parse("9 dl") + Volume.Parse("3 ml").
Or similar with Volume.FromLiters(2) + .....
Replies: 1 comment 3 replies
-
Hi, there is no direct support for this in the library today.
The best you can accomplish today, is something like Volume.Parse("2 l") + Volume.Parse("9 dl") + Volume.Parse("3 ml").
Or similar with Volume.FromLiters(2) + .....
Beta Was this translation helpful? Give feedback.
All reactions
-
thank you, that is a great solution for me
Beta Was this translation helpful? Give feedback.
All reactions
-
I need a way to parse a string containing an enumeration of same quantity type (for example, "1 h 15 minute").
This could easily be achieved by parsing first "1 h" non greedily from "1 h 15 minute" and returning the number of char consumed (3). We could then iterate and check same quantity and different unit.
This could be usefull in configuration file.
Beta Was this translation helpful? Give feedback.
All reactions
-
We actually had this in v3 (#81), and removed support for it in v4
#180 (comment)
It complicated the parsing code quite a bit, and there were some issues like
#343
Also, we realized the feature was mainly used for feet-inches at that time anyways, so it was removed as a generic implementation until.. I guess, until someone came asking for it, like now.
We kept the special parsing as its own method for feet-inches, so this does work:
Length.ParseFeetInches("2' 4\"")
I'm sure this could be revisited, but I still think it is a good idea to distinguish normal Parse() from parsing multiple quantities in the same string.
I don't have the time myself, but if you are interested in attempting a pull request I'm happy to assist.
Beta Was this translation helpful? Give feedback.