From 290449077a2541f87d836bb6fd9f553b44994134 Mon Sep 17 00:00:00 2001 From: Macintxsh <95250141+mctaylors@users.noreply.github.com> Date: Sun, 28 Jan 2024 21:36:29 +0300 Subject: [PATCH] Use TimeSpanParser.TryParse instead of ParseTimeSpan (#257) The ParseTimeSpan method is not needed because we no longer use the quirky (IMO) and long `Parser.TryParseAsync(from).AsTask().GetAwaiter().GetResult()` to parse TimeSpan Signed-off-by: mctaylors --- src/Data/Options/TimeSpanOption.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Data/Options/TimeSpanOption.cs b/src/Data/Options/TimeSpanOption.cs index b9b405f..c81a02d 100644 --- a/src/Data/Options/TimeSpanOption.cs +++ b/src/Data/Options/TimeSpanOption.cs @@ -11,12 +11,12 @@ public sealed class TimeSpanOption : Option public override TimeSpan Get(JsonNode settings) { var property = settings[Name]; - return property != null ? ParseTimeSpan(property.GetValue()).Entity : DefaultValue; + return property != null ? TimeSpanParser.TryParse(property.GetValue()).Entity : DefaultValue; } public override Result Set(JsonNode settings, string from) { - if (!ParseTimeSpan(from).IsDefined(out var span)) + if (!TimeSpanParser.TryParse(from).IsDefined(out var span)) { return new ArgumentInvalidError(nameof(from), Messages.InvalidSettingValue); } @@ -24,9 +24,4 @@ public sealed class TimeSpanOption : Option settings[Name] = span.ToString(); return Result.FromSuccess(); } - - private static Result ParseTimeSpan(string from) - { - return TimeSpanParser.TryParse(from); - } }