Skip to content

Commit b27ab41

Browse files
authored
Merge pull request #531 from tmilnthorp/IQuantityTAdditions
Adding additional functionality to IQuantity<UnitType>
2 parents 355f82f + 40a551e commit b27ab41

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

UnitsNet/IQuantity.cs

+38
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// THE SOFTWARE.
2121

2222
using System;
23+
using JetBrains.Annotations;
2324

2425
namespace UnitsNet
2526
{
@@ -46,6 +47,7 @@ BaseDimensions Dimensions
4647
}
4748

4849
#if !WINDOWS_UWP
50+
4951
public interface IQuantity<UnitType> : IQuantity where UnitType : Enum
5052
{
5153
/// <summary>
@@ -60,6 +62,42 @@ public interface IQuantity<UnitType> : IQuantity where UnitType : Enum
6062
/// <param name="unit">Unit representation to use.</param>
6163
/// <returns>String representation.</returns>
6264
string ToString(UnitType unit);
65+
66+
/// <summary>
67+
/// Get string representation of value and unit. Using two significant digits after radix.
68+
/// </summary>
69+
/// <param name="unit">Unit representation to use.</param>
70+
/// <returns>String representation.</returns>
71+
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
72+
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider);
73+
74+
/// <summary>
75+
/// Get string representation of value and unit.
76+
/// </summary>
77+
/// <param name="unit">Unit representation to use.</param>
78+
/// <param name="significantDigitsAfterRadix">The number of significant digits after the radix point.</param>
79+
/// <returns>String representation.</returns>
80+
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
81+
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix);
82+
83+
/// <summary>
84+
/// Get string representation of value and unit.
85+
/// </summary>
86+
/// <param name="unit">Unit representation to use.</param>
87+
/// <param name="format">String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively."</param>
88+
/// <param name="args">Arguments for string format. Value and unit are implictly included as arguments 0 and 1.</param>
89+
/// <returns>String representation.</returns>
90+
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
91+
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args);
92+
93+
/// <summary>
94+
/// The unit this quantity was constructed with or the BaseUnit if the default constructor was used.
95+
/// </summary>
96+
UnitType Unit
97+
{
98+
get;
99+
}
63100
}
101+
64102
#endif
65103
}

0 commit comments

Comments
 (0)