I know that is not the best solution but I need to add attributes (and relative methods get/set) on a class dynamically: each time the attribute names (and values of course) must be differents.
Why? Simple.
I have to use a class to print some CSV, (CsvBuilderService).
This class is initialized taking another class:
CSVBuilderService<DTO> builder = new CSVBuilderService<DTO>();
Now the CSVBuilderService is initialized to print a list of DTO, the attribute names of DTO are used as columns and the values as rows.
The problem is: the DTO format can change every time, different column names and a different number of columns. (they are query results from different tables each time).
So, I have to add dynamically each time a different number of attributes to DTO with different names, someone has an idea to achieve this?
I didn't search another method to make the CSV since i must use CsvBuilder, i can't use any other methods.