khalidabuhakmeh / ConsoleTables

Print out a nicely formatted table in a console application C#
MIT License
944 stars 157 forks source link

Support nested collections #63

Open Jogai opened 1 year ago

Jogai commented 1 year ago

given:

    new Creator{Id = 1, FullName = @"Douglas Adams", Born = new DateOnly(1952,4,11), Died = new DateOnly(2001,5,11)};
    new Work{Id = 41, CreatorId = 1, Title = @"Young Zaphod Plays It Safe"};

Result:

     ---------------------------------------------------------------------------------------------------------------------- 
     | Id | FullName      | Born       | Died       | PrimaryLanguage | Works                                             |
     ---------------------------------------------------------------------------------------------------------------------- 
     | 1  | Douglas Adams | 04/11/1952 | 05/11/2001 |                 | System.Collections.ObjectModel.Collection`1[Work] |
     ---------------------------------------------------------------------------------------------------------------------- 

It would be really nice if instead of System.Collections.ObjectModel.Collection1[Work]` the following table was inserted:


     -------------------------------------------------------------------- 
     | Id | Title                      | Language | CreatorId | Creator |
     -------------------------------------------------------------------- 
     | 41 | Young Zaphod Plays It Safe |          | 1         | Creator |
     -------------------------------------------------------------------- 
ericnewton76 commented 1 month ago

just build the internal table with each row as a string and add it to the outer table.