Fix batch editor filter check

passing an object with a type from another assembly will have
obj.GetType() return a System.RuntimeType, which is absolutely not what
we want.

supply the pkm derived GetType

why is this so wonky

Closes #1266
This commit is contained in:
Kurt 2017-06-23 21:19:19 -07:00
parent 2822a55d53
commit a4c0927d9c

View file

@ -382,7 +382,7 @@ namespace PKHeX.WinForms
}
private sealed class PKMInfo
{
private readonly PKM pkm;
internal PKM pkm { get; }
internal PKMInfo(PKM pk) { pkm = pk; }
private LegalityAnalysis la;
@ -477,7 +477,7 @@ namespace PKHeX.WinForms
return true;
}
if (!pkm.HasPropertyAll(cmd.PropertyName)
|| ReflectFrameworkUtil.IsValueEqual(pkm, cmd.PropertyName, cmd.PropertyValue) != cmd.Evaluator)
|| pkm.IsValueEqual(info.pkm, cmd.PropertyName, cmd.PropertyValue) != cmd.Evaluator)
{
result = ModifyResult.Filtered;
return true;
@ -567,9 +567,9 @@ namespace PKHeX.WinForms
public static class ReflectFrameworkUtil
{
public static bool IsValueEqual(object obj, string propertyName, object value)
public static bool IsValueEqual(this Type t, object obj, string propertyName, object value)
{
PropertyInfo pi = obj.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
PropertyInfo pi = t.GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
var v = pi.GetValue(obj, null);
var c = ConvertValue(value, pi.PropertyType);
return v.Equals(c);