Skip to content

Adding additional functionality to IQuantity<UnitType> #531

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

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions UnitsNet/IQuantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// THE SOFTWARE.

using System;
using JetBrains.Annotations;

namespace UnitsNet
{
Expand All @@ -46,6 +47,7 @@ BaseDimensions Dimensions
}

#if !WINDOWS_UWP

public interface IQuantity<UnitType> : IQuantity where UnitType : Enum
{
/// <summary>
Expand All @@ -60,6 +62,42 @@ public interface IQuantity<UnitType> : IQuantity where UnitType : Enum
/// <param name="unit">Unit representation to use.</param>
/// <returns>String representation.</returns>
string ToString(UnitType unit);

/// <summary>
/// Get string representation of value and unit. Using two significant digits after radix.
/// </summary>
/// <param name="unit">Unit representation to use.</param>
/// <returns>String representation.</returns>
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider);

/// <summary>
/// Get string representation of value and unit.
/// </summary>
/// <param name="unit">Unit representation to use.</param>
/// <param name="significantDigitsAfterRadix">The number of significant digits after the radix point.</param>
/// <returns>String representation.</returns>
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix);

/// <summary>
/// Get string representation of value and unit.
/// </summary>
/// <param name="unit">Unit representation to use.</param>
/// <param name="format">String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively."</param>
/// <param name="args">Arguments for string format. Value and unit are implictly included as arguments 0 and 1.</param>
/// <returns>String representation.</returns>
/// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param>
string ToString(UnitType unit, [CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args);

/// <summary>
/// The unit this quantity was constructed with or the BaseUnit if the default constructor was used.
/// </summary>
UnitType Unit
{
get;
}
}

#endif
}