"All checks have failed" :(
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
bbddb3790a
commit
92a8d1da4b
5 changed files with 7 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Reference in a new issue