Fix EmptyBinder not identifying inheritance.

This commit is contained in:
2023-01-27 15:24:48 +08:00
parent 46870e163a
commit 3fdc236b1d

View File

@@ -33,12 +33,12 @@ namespace Cryville.Common {
public override object ChangeType(object value, Type type, CultureInfo culture) { public override object ChangeType(object value, Type type, CultureInfo culture) {
if (value == null) if (value == null)
return null; return null;
else if (type == value.GetType()) else if (type.IsAssignableFrom(value.GetType()))
return value; return value;
else if (type.IsEnum && value is string) { else if (type.IsEnum && value is string) {
return Enum.Parse(type, (string)value); return Enum.Parse(type, (string)value);
} }
throw new InvalidCastException(); throw new InvalidCastException(string.Format("Cannot cast {0} to {1}", value.GetType(), type));
} }
public override void ReorderArgumentArray(ref object[] args, object state) { public override void ReorderArgumentArray(ref object[] args, object state) {