mikewlange
5/16/2017 - 7:55 PM

This is how you access necessary private fields in closed source libraries without having to decompile and recode their spaghetti.

This is how you access necessary private fields in closed source libraries without having to decompile and recode their spaghetti.


 public static T GetPrField<T>(this object obj, string name)
    {
        BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
        Type type = obj.GetType();
        FieldInfo field = type.GetField(name, flags);
        return (T)field.GetValue(obj);
    }