2022-06-07 02:40:31 +00:00
|
|
|
using System;
|
|
|
|
|
2022-06-07 13:55:13 +00:00
|
|
|
using NodaTime;
|
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
namespace MfGames.Nitride.Temporal;
|
2022-06-07 02:40:31 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Configures the temporal settings for use with `UseTemporal`.
|
|
|
|
/// </summary>
|
|
|
|
[WithProperties]
|
|
|
|
public partial class NitrideTemporalConfiguration
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Adds the "--date=XXXX-XX-XX" option into the pipeline commands.
|
|
|
|
/// </summary>
|
|
|
|
public bool AddDateOptionToCommandLine { get; set; }
|
|
|
|
|
|
|
|
public bool AddExpireOptionToCommandLine { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the time zone to use for date time operations. Examples would be
|
|
|
|
/// "America/Chicago".
|
|
|
|
/// </summary>
|
2022-06-07 13:55:13 +00:00
|
|
|
public DateTimeZone? DateTimeZone { get; set; }
|
2022-06-07 02:40:31 +00:00
|
|
|
|
|
|
|
public string? Expiration { get; set; }
|
|
|
|
|
2022-06-07 03:07:39 +00:00
|
|
|
public NitrideTemporalConfiguration WithDateOptionCommandLineOption()
|
|
|
|
{
|
|
|
|
return this.WithAddDateOptionToCommandLine(true);
|
|
|
|
}
|
|
|
|
|
2022-06-07 13:55:13 +00:00
|
|
|
public NitrideTemporalConfiguration WithDateTimeZone(string zoneName)
|
|
|
|
{
|
|
|
|
this.DateTimeZone = DateTimeZoneProviders.Tzdb[zoneName];
|
2022-07-09 04:52:10 +00:00
|
|
|
|
2022-06-07 13:55:13 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-06-07 02:40:31 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds the "--expire" option into the pipeline commands where with the value set
|
|
|
|
/// to
|
|
|
|
/// the current timestamp (or the one provided by --date) plus the given timespan
|
|
|
|
/// such
|
|
|
|
/// as "500000:00:00.0".
|
|
|
|
/// </summary>
|
2023-01-15 00:19:42 +00:00
|
|
|
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
|
|
|
|
TimeSpan? timeSpan)
|
2022-06-07 02:40:31 +00:00
|
|
|
{
|
|
|
|
return this.WithExpiresCommandLineOption(timeSpan?.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds the "--expire=XXXX" option into the pipeline commands where
|
|
|
|
/// "XXX" is a format like "5y" or "500000:00:00.0". This is parsed by
|
|
|
|
/// TimeSpanParser which gives an easy format.
|
|
|
|
/// </summary>
|
2023-01-15 00:19:42 +00:00
|
|
|
public NitrideTemporalConfiguration WithExpiresCommandLineOption(
|
|
|
|
string? defaultValue)
|
2022-06-07 02:40:31 +00:00
|
|
|
{
|
|
|
|
this.AddExpireOptionToCommandLine = defaultValue != null;
|
|
|
|
this.Expiration = defaultValue;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|