/// <summary> /// this version will first fetch the struct before getting/setting values on it when invoking the getter/setter /// </summary> /// <returns>The struct target.</returns> /// <param name="target">Target.</param> /// <param name="structName">Struct name.</param> /// <param name="field">Field.</param> public void setStructTarget(object target, Inspector parentInspector, PropertyInfo prop) { _target = target; _memberInfo = prop; _name = prop.Name; _valueType = prop.PropertyType; _getter = () => { var structValue = parentInspector.getValue(); return(ReflectionUtils.getPropertyGetter(prop).Invoke(structValue, null)); }; _setter = (val) => { var structValue = parentInspector.getValue(); prop.SetValue(structValue, val); parentInspector.setValue(structValue); }; }
/// <summary> /// this version will first fetch the struct before getting/setting values on it when invoking the getter/setter /// </summary> /// <returns>The struct target.</returns> /// <param name="target">Target.</param> /// <param name="structName">Struct name.</param> /// <param name="field">Field.</param> public void setStructTarget(object target, Inspector parentInspector, FieldInfo field) { _target = target; _memberInfo = field; _name = field.Name; _valueType = field.FieldType; _getter = () => { var structValue = parentInspector.getValue(); return(field.GetValue(structValue)); }; _setter = (val) => { var structValue = parentInspector.getValue(); field.SetValue(structValue, val); parentInspector.setValue(structValue); }; }