Exemplo n.º 1
0
        /// <summary>
        /// Add properties to an existing EditInterface.
        /// </summary>
        /// <param name="scanner"></param>
        /// <param name="target"></param>
        /// <param name="edit"></param>
        private static void addProperties(MemberScanner scanner, Object target, Type startType, EditInterface edit, ReflectedEditablePropertyProvider customPropProvider)
        {
            IEnumerable <MemberWrapper> members = scanner.getMatchingMembers(startType);

            foreach (MemberWrapper memberWrapper in members)
            {
                if (!customPropProvider.addProperties(memberWrapper, target, edit))
                {
                    EditableAttribute editable = findEditableAttribute(memberWrapper);
                    bool addAsProperty         = (editable != null && editable.ForceAsProperty) || ReflectedVariable.canCreateVariable(memberWrapper.getWrappedType());
                    if (addAsProperty)
                    {
                        edit.addEditableProperty(editable.createEditableProperty(memberWrapper, target));
                    }
                    else
                    {
                        Object subObject = memberWrapper.getValue(target, null);
                        if (subObject is EditInterfaceOverride)
                        {
                            EditInterfaceOverride custom = (EditInterfaceOverride)subObject;
                            edit.addSubInterface(custom.getEditInterface(memberWrapper.getWrappedName(), scanner));
                        }
                        else if (subObject != null)
                        {
                            edit.addSubInterface(createEditInterface(subObject, scanner, memberWrapper.getWrappedName() + " - " + memberWrapper.getWrappedType(), null));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static EditableAttribute findEditableAttribute(MemberWrapper memberWrapper)
        {
            EditableAttribute editable = memberWrapper.getCustomAttributes(typeof(EditableAttribute), true).Select(s => (EditableAttribute)s).FirstOrDefault();

            if (editable != null)
            {
                return(editable);
            }
            return(defaultEditableAttribute);
        }