jeudi 16 juillet 2020

Design pattern - variable objects to excel file

I have a case, in c#, where i read an xml file with variable number of specific objects in the form of

<car>
    <carType>some-type</carType>
    <objects>
      <object>
         <id>1</id>
         <name>wheel</name>
      </object>
      <object>
         <id>2</id>
         <name>engine</name>
      </object>
    </objects>
</car>

and i need to pass the name in a pivot table in an excel file. The problem is that according to a car type tag there will be a different excel and different types and number of objects.

Is there a design pattern to make this more dynamic and not use a switch or if statement and every time a new car type appears not be necessary to update the code?

Aucun commentaire:

Enregistrer un commentaire