private bool InspectDeepness(ClassMember cm, TextWriter tw, int depth)
        {
            if (depth >= Settings.MaxDepth)
            {
                _formatter.WriteText(string.Format("{0}{1}{2}", "{", cm.GetClassMemberType().ToString(), "}"), 0, tw);
                return(true);
            }

            return(false);
        }
예제 #2
0
        internal IEnumerable <TraverseNode> GetChildren(ObjectDumperSettings settings)
        {
            List <TraverseNode> children = new List <TraverseNode>();

            if (Item == null || Item is ValueType || Item is string)
            {
                return(children);
            }

            if (Item is IEnumerable)
            {
                return(children);
            }

            List <MemberInfo> members = Item.GetType().GetMembers(settings.BindingFlags).ToList();

            foreach (MemberInfo member in members)
            {
                Type type = member.DeclaringType;
                if (type.FullName.Equals($"System.{type.Name}", StringComparison.Ordinal))
                {
                    continue;
                }

                if (type.FullName.Equals($"System.Reflection.{type.Name}", StringComparison.Ordinal))
                {
                    continue;
                }

                if (IgnoreCompilerGeneratedMember(member, settings))
                {
                    continue;
                }

                ClassMember cm = new ClassMember(member);
                if (cm.IsValid())
                {
                    object value = cm.GetValue(Item);
                    children.Add(new TraverseNode(cm.GetName(), cm.GetClassMemberType().FullName, value, this, Level + 1));
                }
            }

            return(children.OrderBy(x => x.Name));
        }