/// <inheritdoc /> public override void VisitValueList(object owner, ListValueReflection reflection) { if (Loader.OnValueList(reflection, out IList list)) { CopyList(list, reflection.GetMember(owner) as IList, reflection.ValueType); } }
public static ListValueReflection Create( MemberInfo mi, ConfigValueAttribute attribute = null, Type valueType = null ) { var reflection = new ListValueReflection(); if (valueType != null) { reflection.ValueType = valueType; } return(Factory(reflection, mi, attribute)); }
/// <inheritdoc /> public override void VisitValueList(object owner, ListValueReflection reflection) { if (!(reflection.GetMember(owner) is IList member)) { return; } for (int i = 0; i < member.Count; i++) { if (Saver.OnListValue(i, member[i], reflection, out object newValue)) { member[i] = newValue; } } }
private void SetupType(MemberInfo mi, Type memberType) { // if ignored, nothing to do if (mi?.GetCustomAttribute <ConfigValueIgnoreAttribute>() != null) { return; } // check if the type is a node and contains ConfigValueAttribute ConfigNodeAttribute node = memberType.GetCustomAttribute <ConfigNodeAttribute>(); ConfigValueAttribute value = mi?.GetCustomAttribute <ConfigValueAttribute>(); // try to get the list value type Type listValueType = ReflectionUtils.ListType(ReflectionUtils.ConfigValueType(memberType) ?? memberType); if (listValueType != null) { // is a list var reflection = ListValueReflection.Create(mi, value, listValueType); ListValues.Add(reflection); FARLogger.TraceFormat("Added list value '{1} -> <{0}, {2}>'", reflection.Name ?? "{null}", reflection.NodeId ?? "{null}", reflection.ValueType); } else if (node == null) { // not a node or a list -> simple value ValueReflection reflection = Create(mi, value); Values.Add(reflection); FARLogger.TraceFormat("Added value '{0} -> {1}'", reflection.Name, reflection.ValueType); } else { // ConfigValue name string name = value?.Name; // get clone or create new reflection for the type NodeReflection nodeReflection = GetReflection(memberType, true, name, mi); Nodes.Add(nodeReflection); FARLogger.TraceFormat("Added node '{1} -> <{0}, {2}>'", name ?? "{null}", nodeReflection.Id, nodeReflection.ValueType); } }
public abstract void VisitNodeList( object owner, ListValueReflection reflection, NodeReflection nodeReflection );