コード例 #1
0
        internal static IEnumerable <HierarchyPropertyNode> BuildPropertyList(this Type baseType, bool ExpandNonPrimitiveClass = false, ExpandPropertyOptions expandPropertyOptions = null, HierarchyPropertyNode parent = null)
        {
            if (expandPropertyOptions == null)
            {
                expandPropertyOptions = new ExpandPropertyOptions();
            }
            PropertyInfo[] properties        = baseType.GetProperties();
            List <HierarchyPropertyNode> res = new List <HierarchyPropertyNode>();

            PropertyInfo[] array = properties;
            foreach (PropertyInfo prop in array)
            {
                HierarchyPropertyNode hpn = new HierarchyPropertyNode
                {
                    parent   = parent,
                    Property = prop
                };
                res.Add(hpn);
                if (ExpandNonPrimitiveClass && prop.PropertyType.CanExpand() && expandPropertyOptions.CanExpand(hpn))
                {
                    res.AddRange(prop.PropertyType.BuildPropertyList(ExpandNonPrimitiveClass, expandPropertyOptions, hpn));
                }
            }
            return(res);
        }
コード例 #2
0
            internal bool CanExpand(HierarchyPropertyNode hpn)
            {
                bool result = true;

                if (hpn.Level >= MaxReferenceLevel)
                {
                    result = false;
                }
                if (!ExpandCircularReference && hpn.IsCircularReference)
                {
                    result = false;
                }
                if (IncludeProperties.Any() && !IncludeProperties.Contains(hpn.PropertyName))
                {
                    result = false;
                }
                return(result);
            }