Example #1
0
        /// <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);
            };
        }
Example #2
0
        /// <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);
            };
        }