console: correctly treat null default values, return result from commands

This commit is contained in:
goat 2024-06-07 22:52:33 +02:00
parent 0f2aaa4241
commit c0867d887e

View file

@ -384,6 +384,9 @@ internal partial class ConsoleManager : IServiceType
/// <exception cref="ArgumentException">Thrown if the given type cannot be handled by the console system.</exception> /// <exception cref="ArgumentException">Thrown if the given type cannot be handled by the console system.</exception>
protected static ArgumentInfo TypeToArgument(Type type, object? defaultValue = null) protected static ArgumentInfo TypeToArgument(Type type, object? defaultValue = null)
{ {
// If the default value is DBNull, we want to treat it as null
defaultValue = defaultValue == DBNull.Value ? null : defaultValue;
if (type == typeof(string)) if (type == typeof(string))
return new ArgumentInfo(ConsoleArgumentType.String, defaultValue); return new ArgumentInfo(ConsoleArgumentType.String, defaultValue);
@ -462,8 +465,7 @@ internal partial class ConsoleManager : IServiceType
/// <inheritdoc cref="ConsoleEntry.Invoke" /> /// <inheritdoc cref="ConsoleEntry.Invoke" />
public override bool Invoke(IEnumerable<object> arguments) public override bool Invoke(IEnumerable<object> arguments)
{ {
this.func.DynamicInvoke(arguments.ToArray()); return (bool)this.func.DynamicInvoke(arguments.ToArray())!;
return true;
} }
} }