Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Dump information about the current executable file
            var fi = new FileInfo(Assembly.GetExecutingAssembly().Location);

            // Dumping file info
            Console.WriteLine("--- FileInfo for the current assembly ---");
            Console.WriteLine(Dump.ToDump(fi, "FileInfo"));

            // Dumping a temp object
            Console.WriteLine();
            Console.WriteLine("--- Dumping a temp object ---");
            Console.WriteLine(Dump.ToDump(new
            {
                A = "Hello, world",
                B = 21.45,
                C = new object[]
                {
                    new { X = 20 },
                    new { Y = 20 },
                }
            }, "Dump for temp class"));

            // Array
            Console.WriteLine();
            Console.WriteLine("--- Array ---");
            Console.WriteLine(Dump.ToDump(Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.System))));

            // Byte array
            Console.WriteLine();
            Console.WriteLine("--- Byte Array ---");
            Console.WriteLine(Dump.ToDump(Encoding.UTF8.GetBytes("Hello, world!")));

            // Add hidden property
            Dump.AddHiddenProperty(typeof(TreeElement), "SideEffectProperty");

            // Dumping a bad object (long tree)

            Console.WriteLine();
            Console.WriteLine("--- Object with broken property ---");
            Console.WriteLine(Dump.ToDump(new TreeElement("Before")));

            // Fixing the bad property
            Dump.AddBloatProperty(typeof(TreeElement), "BadProperty");
            Console.WriteLine();
            Console.WriteLine("--- Object with opaque property ---");
            Console.WriteLine(Dump.ToDump(new TreeElement("Before")));

            // Tree with loops
            TreeElement root  = new TreeElement("0-Root");
            TreeElement left  = new TreeElement("1-Left", root, null);
            TreeElement right = new TreeElement("1-Right", new TreeElement("2-Right-Left"), new TreeElement("2-Right-Right"));

            root.Left  = left;
            root.Right = right;
            Console.WriteLine();
            Console.WriteLine("--- Object tree with loops ---");
            Console.WriteLine(Dump.ToDump(root));

            // Function call
            Console.WriteLine();
            Console.WriteLine("--- Function call throwing exception ---");
            root.InvalidApi(3, "Hello", left);

            Console.WriteLine("=== Press Enter to close ===");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Dump information about the current executable file
            var fi = new FileInfo(Assembly.GetExecutingAssembly().Location);

            // Dumping file info
            Console.WriteLine("--- FileInfo for the current assembly ---");
            Console.WriteLine(Dump.ToDump(fi,"FileInfo"));

            // Dumping a temp object
            Console.WriteLine();
            Console.WriteLine("--- Dumping a temp object ---");
            Console.WriteLine(Dump.ToDump(new
                {
                    A="Hello, world",
                    B=21.45,
                    C=new object[]
                        {
                          new { X=20},
                          new { Y=20},
                        }
                }, "Dump for temp class"));

            // Array
            Console.WriteLine();
            Console.WriteLine("--- Array ---");
            Console.WriteLine(Dump.ToDump(Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.System))));

            // Byte array
            Console.WriteLine();
            Console.WriteLine("--- Byte Array ---");
            Console.WriteLine(Dump.ToDump(Encoding.UTF8.GetBytes("Hello, world!")));

            // Add hidden property
            Dump.AddHiddenProperty(typeof(TreeElement), "SideEffectProperty");

            // Dumping a bad object (long tree)

            Console.WriteLine();
            Console.WriteLine("--- Object with broken property ---");
            Console.WriteLine(Dump.ToDump(new TreeElement("Before")));

            // Fixing the bad property
            Dump.AddBloatProperty(typeof(TreeElement),"BadProperty");
            Console.WriteLine();
            Console.WriteLine("--- Object with opaque property ---");
            Console.WriteLine(Dump.ToDump(new TreeElement("Before")));

            // Tree with loops
            TreeElement root=new TreeElement("0-Root");
            TreeElement left = new TreeElement("1-Left",root,null);
            TreeElement right = new TreeElement("1-Right", new TreeElement("2-Right-Left"), new TreeElement("2-Right-Right"));
            root.Left = left;
            root.Right = right;
            Console.WriteLine();
            Console.WriteLine("--- Object tree with loops ---");
            Console.WriteLine(Dump.ToDump(root));

            // Function call
            Console.WriteLine();
            Console.WriteLine("--- Function call throwing exception ---");
            root.InvalidApi(3,"Hello",left);

            Console.WriteLine("=== Press Enter to close ===");
            Console.ReadLine();
        }