mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-26 18:42:48 -05:00
Split from the existing form, now can handle multiple generations. Need to rename / add ribbon images so that they show up in the box. WIP.
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace PKHeX
|
|
{
|
|
public static class ReflectUtil
|
|
{
|
|
internal static bool GetValueEquals(object obj, string propertyName, object value)
|
|
{
|
|
PropertyInfo pi = obj.GetType().GetProperty(propertyName);
|
|
var v = pi.GetValue(obj, null);
|
|
var c = Convert.ChangeType(value, pi.PropertyType);
|
|
return v.Equals(c);
|
|
}
|
|
internal static void SetValue(object obj, string propertyName, object value)
|
|
{
|
|
PropertyInfo pi = obj.GetType().GetProperty(propertyName);
|
|
pi.SetValue(obj, Convert.ChangeType(value, pi.PropertyType), null);
|
|
}
|
|
internal static object GetValue(object obj, string propertyName)
|
|
{
|
|
PropertyInfo pi = obj.GetType().GetProperty(propertyName);
|
|
return pi.GetValue(obj, null);
|
|
}
|
|
internal static IEnumerable<string> getPropertiesStartWithPrefix(Type type, string prefix)
|
|
{
|
|
return type.GetProperties()
|
|
.Where(p => p.Name.StartsWith(prefix))
|
|
.Select(p => p.Name);
|
|
}
|
|
}
|
|
}
|