示例#1
0
        private List <IMemberAccessor> FindAccessors()
        {
            var result = new List <IMemberAccessor>();
            var fields = _type.GetFields(BindingFlags.Public | BindingFlags.Instance);
            var props  = _type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var all    = fields.Concat <MemberInfo>(props);

            foreach (var mem in all)
            {
                var attr   = mem.GetCustomAttribute <DebuggerBrowsableAttribute>();
                var access = MemberAccessors.PropertyOrField(mem);

                if (attr == null)
                {
                    result.Add(access);
                    continue;
                }

                switch (attr.State)
                {
                case DebuggerBrowsableState.Never:
                    break;

                case DebuggerBrowsableState.Collapsed:
                    result.Add(new CollapsedImpl(mem.Name));
                    break;

                case DebuggerBrowsableState.RootHidden:
                    IList <IMemberAccessor> accessors;
                    try {
                        accessors = DisplayActualSchema.Create(access.ReturnType).Accessors;
                    } catch (InvalidOperationException) {
                        // There was a circular dependency in the type dependency graph because
                        // we tried to resolve the factory value of a schema that is already in
                        // progress of being written.  Handle this by collapsing
                        result.Add(new CollapsedImpl(mem.Name));
                        break;
                    }
                    result.AddRange(
                        accessors.Select(a => HideRoot(access, a))
                        );
                    break;
                }
            }
            result.Sort((x, y) => x.Name.CompareTo(y.Name));
            return(result);
        }
            public DefaultDisplayActual(object value, int depth, ObjectIDGenerator graph)
            {
                _schema = DisplayActualSchema.Create(value.GetType());
                depth  += 1;

                foreach (var accessor in _schema.Accessors)
                {
                    IDisplayActual pv;
                    try {
                        pv = DisplayActual.Create(DisplayActual.Create(accessor.GetValue(value), depth, graph));
                    } catch (Exception ex) {
                        ex = Record.UnwindTargetException(ex);
                        pv = DisplayActual.Create($"<{ex.GetType().Name}>");
                    }

                    _entries.Add(
                        (accessor.Name, pv)
                        );
                }
            }