"All checks have failed" :(

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-11 00:37:54 +05:00
parent bbddb3790a
commit 92a8d1da4b
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
5 changed files with 7 additions and 11 deletions

View file

@ -4,7 +4,7 @@ using Remora.Results;
namespace Boyfriend.Data.Options;
public interface IOption {
string Name { get; init; }
string Name { get; }
object GetAsObject(JsonNode settings);
Result Set(JsonNode settings, string from);
}

View file

@ -15,7 +15,6 @@ public class Option<T> : IOption {
DefaultValue = defaultValue;
}
public Type Type { get; set; } = typeof(T);
public string Name { get; init; }
public object GetAsObject(JsonNode settings) {

View file

@ -11,7 +11,9 @@ public class TimeSpanOption : Option<TimeSpan> {
public TimeSpanOption(string name, TimeSpan defaultValue) : base(name, defaultValue) { }
public override Result Set(JsonNode settings, string from) {
if (!Parser.TryParseAsync(from).Result.IsDefined(out var span))
var task = Parser.TryParseAsync(from).AsTask().GetAwaiter().GetResult();
if (task.IsDefined(out var span))
return Result.FromError(new ArgumentInvalidError(nameof(from), Messages.InvalidSettingValue));
settings[Name] = span.ToString();