Skip to content

QuantityInfo.MinValue and QuantityInfo.MaxValue are missing #848

Closed
@bitbonk

Description

@bitbonk

Is your feature request related to a problem? Please describe.
For a generic (WPF) UI where you can input any type of quantity, we need the ability to configure the maximum and minimum bounds that the user is currently allowed to enter for a given value. If the user can enter any value (unbounded), the bounds should be set to the minimum and maximum that the given quantity type generally allows. Unfortunately there is no generic way to determine the minimum and maximum of a given quantity type. Although all quantities have the concrete properties like Pressure.MinValue and Pressure.MaxValue, there is no generic/polymorph way to determine these values without knowing the quantity type at compile time.

Describe the solution you'd like
Introduce the properties QuantityInfo.MinValue and QuantityInfo.MaxValue, just like you have already introduced the properety QuantityInfo.Zero:

    /// <summary>
    ///     Minimum value of quantity, such as <see cref="P:UnitsNet.Length.MinValue" />.
    /// </summary>
    public IQuantity MinValue { get; }

    /// <summary>
    ///     Maximum value of quantity, such as <see cref="P:UnitsNet.Length.MaxValue" />.
    /// </summary>
    public IQuantity MaxValue { get; }

Describe alternatives you've considered
We are currently using the following code:

(IQuantity)quantityInfo.ValueType.GetProperty("MinValue").GetValue(null)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions