From 40a551e6b76d2c9505253aa4c2cc779ae90adf5f Mon Sep 17 00:00:00 2001 From: Tristan Milnthorp Date: Mon, 22 Oct 2018 17:00:57 -0400 Subject: [PATCH] Adding additional functionality to IQuantity --- UnitsNet/IQuantity.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 07d0c250a0..611d440ff9 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -20,6 +20,7 @@ // THE SOFTWARE. using System; +using JetBrains.Annotations; namespace UnitsNet { @@ -46,6 +47,7 @@ BaseDimensions Dimensions } #if !WINDOWS_UWP + public interface IQuantity : IQuantity where UnitType : Enum { /// @@ -60,6 +62,42 @@ public interface IQuantity : IQuantity where UnitType : Enum /// Unit representation to use. /// String representation. string ToString(UnitType unit); + + /// + /// Get string representation of value and unit. Using two significant digits after radix. + /// + /// Unit representation to use. + /// String representation. + /// Format to use for localization and number formatting. Defaults to if null. + string ToString(UnitType unit, [CanBeNull] IFormatProvider provider); + + /// + /// Get string representation of value and unit. + /// + /// Unit representation to use. + /// The number of significant digits after the radix point. + /// String representation. + /// Format to use for localization and number formatting. Defaults to if null. + string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix); + + /// + /// Get string representation of value and unit. + /// + /// Unit representation to use. + /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." + /// Arguments for string format. Value and unit are implictly included as arguments 0 and 1. + /// String representation. + /// Format to use for localization and number formatting. Defaults to if null. + string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args); + + /// + /// The unit this quantity was constructed with or the BaseUnit if the default constructor was used. + /// + UnitType Unit + { + get; + } } + #endif }