Skip to content

Commit 4fbae45

Browse files
committed
Added ValueExtensions class with AsRaw extension
1 parent 6c6103a commit 4fbae45

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace Synercoding.Primitives.Extensions
2+
{
3+
/// <summary>
4+
/// Extension methods for <see cref="Value"/>
5+
/// </summary>
6+
public static class ValueExtensions
7+
{
8+
/// <summary>
9+
/// Get a double representing a value in a given unit
10+
/// </summary>
11+
/// <param name="value">The value to get the raw number for</param>
12+
/// <param name="unit">The unit of the returned raw value</param>
13+
/// <returns>A double representing the value</returns>
14+
/// <remarks>
15+
/// Shorthand for <c>value.ConvertTo(unit).Raw</c>
16+
/// </remarks>
17+
public static double AsRaw(this Value value, Unit unit)
18+
=> value.ConvertTo(unit).Raw;
19+
}
20+
}

0 commit comments

Comments
 (0)