Skip to content

Commit 84d85c4

Browse files
committed
refactor(DurationValue): rename Count to Value for clarity
- Renames the property `Count` to `Value` to better represent the number of units in a duration. - Updates constructor and relevant methods to use `Value`, ensuring clearer semantics in the implementation. - Includes necessary adjustments to validation checks and string representation.
1 parent fb0347e commit 84d85c4

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/ES.FX/Primitives/DurationValue.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ namespace ES.FX.Primitives;
1111
/// <summary>
1212
/// The number of units.
1313
/// </summary>
14-
public long Count { get; init; }
14+
public long Value { get; init; }
1515

1616
/// <summary>
1717
/// The unit of time for this duration.
1818
/// </summary>
1919
public DurationUnit Unit { get; init; }
2020

2121
/// <summary>
22-
/// Initializes a new <see cref="DurationValue"/> with the specified count and unit,
23-
/// enforcing non-negative counts.
22+
/// Initializes a new <see cref="DurationValue"/> with the specified value and unit,
23+
/// enforcing non-negative values.
2424
/// </summary>
25-
/// <param name="count">The number of units. Must be non-negative.</param>
25+
/// <param name="value">The number of units. Must be non-negative.</param>
2626
/// <param name="unit">The duration unit.</param>
27-
public DurationValue(long count, DurationUnit unit)
27+
public DurationValue(long value, DurationUnit unit)
2828
{
29-
if (count < 0)
30-
throw new ArgumentOutOfRangeException(nameof(count), "Count must be non-negative");
29+
if (value < 0)
30+
throw new ArgumentOutOfRangeException(nameof(value), "Value must be non-negative");
3131

32-
Count = count;
32+
Value = value;
3333
Unit = unit;
3434
}
3535

3636
/// <summary>
3737
/// Returns a string such as "7 Days".
3838
/// </summary>
39-
public override string ToString() => $"{Count} {Unit}{(Count == 1 ? string.Empty : "s")}";
39+
public override string ToString() => $"{Value} {Unit}{(Value == 1 ? string.Empty : "s")}";
4040

4141
/// <summary>
4242
/// Compares two durations of the same unit.
@@ -47,6 +47,6 @@ public int CompareTo(DurationValue other)
4747
if (Unit != other.Unit)
4848
throw new InvalidOperationException("Cannot compare durations of different units.");
4949

50-
return Count.CompareTo(other.Count);
50+
return Value.CompareTo(other.Value);
5151
}
5252
}

0 commit comments

Comments
 (0)