| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="TimeSpanDecompositionOptions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using MyNet.Primitives; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Temporal.Decomposition; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Options for decomposing a TimeSpan into its component time units, allowing customization of precision, unit inclusio |
| | | 13 | | /// </summary> |
| | | 14 | | /// <example> |
| | | 15 | | /// Strict mode: |
| | | 16 | | /// new TimeSpanDecompositionOptions { }. |
| | | 17 | | /// Fuzzy mode: |
| | | 18 | | /// new TimeSpanDecompositionOptions { Quantizer = HumanFriendlyTimeSpanQuantizer.Current }. |
| | | 19 | | /// </example> |
| | | 20 | | public sealed class TimeSpanDecompositionOptions |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets the default options for decomposing a TimeSpan, which includes a precision of 1, does not count empty units |
| | | 24 | | /// </summary> |
| | 0 | 25 | | public static TimeSpanDecompositionOptions Default { get; } = TimeSpanDecompositionPresets.Strict; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the minimum time unit to consider in the decomposition. |
| | | 29 | | /// </summary> |
| | | 30 | | public TimeUnit MinUnit { get; init; } = TimeUnit.Millisecond; |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets the maximum time unit to consider in the decomposition. |
| | | 34 | | /// </summary> |
| | | 35 | | public TimeUnit MaxUnit { get; init; } = TimeUnit.Year; |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets the mode for decomposing the TimeSpan into its component time units. This determines how the decomposition |
| | | 39 | | /// </summary> |
| | | 40 | | public TimeSpanDecompositionMode Mode { get; init; } = TimeSpanDecompositionMode.Hierarchical; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets the precision for the decomposition, which determines how many time units to include in the result. For exa |
| | | 44 | | /// </summary> |
| | | 45 | | public int? MaxComponents { get; init; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets a value indicating whether to include time units with zero values in the decomposition result. If true, all |
| | | 49 | | /// </summary> |
| | | 50 | | public bool IncludeZeroUnits { get; init; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Gets the rule engine to use for decomposing the TimeSpan into its component time units. This allows for customiz |
| | | 54 | | /// </summary> |
| | | 55 | | public ITimeUnitRuleEngine RuleEngine { get; init; } = TimeUnitRuleSelector.Default; |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Gets the optional quantizer to apply after exact decomposition. |
| | | 59 | | /// </summary> |
| | | 60 | | public ITimeSpanQuantizer? Quantizer { get; init; } |
| | | 61 | | } |
| | | 62 | | |