Home

Problem getting DumpContainer.DumpDepth working

I have problem understandig how DumpDepth is supposed to be use, see comments in code below

using LINQPad.Controls;
void Main()
{
    var aaa = new AAA(new AA(new A(1, 2), new A(3, 4)), new AA(new A(5, 6), new A(7, 8)));
    var bbb = new BBB(new AA(new A(1, 2), new A(3, 4)), new AA(new A(5, 6), new A(7, 8)));
    //aaa.Dump("aa",depth: 2); // works (dump 2 levelt)
    var dc = new DumpContainer(aaa);
    //dc.DumpDepth = 1; // apparently no effect 
    dc.Dump("dc"); // (dump all 3 levels)
    dc.DumpDepth = 1; // apparently no effect
    bbb.Dump();
}

class AAA {
    public AAA(AA aA1, AA aA2) { AA1 = aA1; AA2 = aA2; }
    public AA AA1 { get; }
    public AA AA2 { get; }
}
class BBB
{
    private AA aA1;
    private AA aA2;
    public BBB(AA aA1, AA aA2) { this.aA1 = aA1; this.aA2 = aA2; }
    public object Expanded {
        get {
            var dc = new DumpContainer();
            Update(false);
            void Update(bool expand)
            {
                dc.Content = new Hyperlink("BB",_ => Update(!expand));
                if (expand)
                {
                    // 2 additional levels dumped to a total of 3
                    dc.DumpDepth = 3; // apparently no effect
                    dc.AppendContent(new AAA(aA1,aA2));
                    //dc.DumpDepth = 3; // apparently no effect
                }
            }
            return dc;
        }
    }   
}
class AA
{
    public AA(A a1, A a2) { A1 = a1; A2 = a2; }
    public A A1 { get; }
    public A A2 { get; }
}
class A
{
    public A(int v1, int v2) { V1 = v1; V2 = v2; }
    public int V1 { get; }
    public int V2 { get; }
}

Comments

Sign In or Register to comment.