-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLength.cs
More file actions
40 lines (36 loc) · 1.75 KB
/
Length.cs
File metadata and controls
40 lines (36 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Quantify.Repository.Enum;
namespace Quantify.Length
{
/// <summary>
/// A quantity that represents a length with one of the units defined in <see cref="Unit"/>.
/// </summary>
/// <remarks>
/// This quantity represents a length where the value is defined by a <see cref="double"/>.
///
/// As opposed to <see cref="PreciseLength"/>, this length quantity is optimized for performance and not precision. Round-off errors might occure.
/// </remarks>
public sealed class Length : Quantity<double, Unit, Length>
{
private Length(double value, Unit unit, UnitRepository<Unit> unitRepository) : base(value, unit, unitRepository)
{
}
private Length(double value, Unit unit, UnitRepository<Unit> unitRepository, ValueCalculator<double> valueCalculator, ValueConverter<double, Unit> valueConverter) : base(value, unit, unitRepository, valueCalculator, valueConverter)
{
}
/// <summary>
/// Created a new instance of <see cref="Length"/> with a value and a unit.
/// </summary>
/// <param name="value">The value of the quantity.</param>
/// <param name="unit">The unit of the quantity.</param>
/// <returns>A new quantity.</returns>
public static Length Create(double value, Unit unit)
{
var unitRepository = new EnumUnitRepository<Unit>();
return new Length(value, unit, unitRepository);
}
protected override Length CreateInstance(double value, Unit unit, UnitRepository<Unit> unitRepository, ValueCalculator<double> valueCalculator, ValueConverter<double, Unit> valueConverter)
{
return new Length(value, unit, unitRepository, valueCalculator, valueConverter);
}
}
}