public bool Process(object?instance, Type instanceType, IObjectDumperResultBuilder builder, int indent, int currentDepth)
    {
        if (instance is ContextDictionary contextClass)
        {
            builder.BeginNesting(indent, instanceType);
            builder.BeginComplexType(indent, instanceType);


            builder.AddEnumerableItem(true, indent, true);
            builder.AddName(indent, nameof(ContextDictionary.Custom1));
            Callback?.Process(contextClass.Custom1, typeof(string), builder, indent + 4, currentDepth + 1);
            builder.AddEnumerableItem(false, indent, true);
            builder.AddName(indent, nameof(ContextDictionary.Custom2));
            Callback?.Process(contextClass.Custom2, typeof(int), builder, indent + 4, currentDepth + 1);

            foreach (var item in contextClass)
            {
                builder.AddEnumerableItem(false, indent, false);
                Callback?.Process(item, item.GetType() ?? instanceType.GetGenericArguments()[0], builder, indent + 4, currentDepth + 1);
            }

            builder.EndComplexType(false, indent, instanceType);

            return(true);
        }

        return(false);
    }
Beispiel #2
0
    public bool Process(object?instance, Type instanceType, IObjectDumperResultBuilder builder, int indent, int currentDepth)
    {
        if (!(instance is string) && instance is IEnumerable enumerable)
        {
            builder.BeginNesting(indent, instanceType);
            builder.BeginEnumerable(indent, instanceType);

            var firstEnum = true;
            foreach (var item in enumerable)
            {
                builder.AddEnumerableItem(firstEnum, indent, false);
                if (firstEnum)
                {
                    firstEnum = false;
                }

                Callback?.Process(item, item?.GetType() ?? instanceType.GetGenericArguments()[0], builder, indent + 4, currentDepth + 1);
            }

            builder.EndEnumerable(indent, instance.GetType());

            return(true);
        }

        return(false);
    }