Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions UnitsNet/GeneratedCode/Quantities/BitRate.NetFramework.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions UnitsNet/GeneratedCode/Quantities/Power.NetFramework.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion UnitsNet/IQuantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace UnitsNet
/// <summary>
/// Represents a quantity.
/// </summary>
public partial interface IQuantity
public interface IQuantity
{
/// <summary>
/// The <see cref="QuantityType" /> of this quantity.
Expand Down Expand Up @@ -58,6 +58,11 @@ public partial interface IQuantity
/// </summary>
Enum Unit { get; }

/// <summary>
/// The value this quantity was constructed with. Should be seen in combination with <see cref="Unit"/>.
/// </summary>
double Value { get; }

/// <summary>
/// Change the default unit representation of the quantity, which affects things like <see cref="IQuantity.ToString(System.IFormatProvider)"/>.
/// </summary>
Expand Down
6 changes: 5 additions & 1 deletion UnitsNet/Scripts/Include-GenerateQuantitySourceCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ function GenerateProperties([GeneratorArgs]$genArgs)
{
$quantityName = $genArgs.Quantity.Name
$unitEnumName = $genArgs.UnitEnumName
$baseUnitSingularName = $genArgs.BaseUnit.SingularName
$valueType = $genArgs.Quantity.BaseType
[bool]$isDoubleValueType = $valueType -eq "double"
@"

#region Properties
Expand All @@ -359,6 +359,10 @@ function GenerateProperties([GeneratorArgs]$genArgs)
/// </summary>
public $valueType Value => _value;

"@; if (-not $isDoubleValueType) { @"
double IQuantity.Value => (double) _value;

"@; } @"
/// <inheritdoc cref="IQuantity.Unit"/>
Enum IQuantity.Unit => Unit;

Expand Down