I have a Windows Form for creating configs. It has around 50 fields of data, which represent a group of entities, that I need to capture when the user presses the save button. Currently, on the press of the save button I build the group of Entities by creating each entity, extracting the information from the controls and then save them to the database.
I am now working on functionality to import the partly built configs from XML. With the way the save button works I would be replicating almost all of the save code to achieve this.
The only alternative I think of was to pass the values of the controls as parameters to a new class that will contain methods that build and return an entity. However, passing ~15 parameters to each entity creator method does not seem to be a clean solution.
Is there any clean way of disconnecting the save logic from the WinForm that will enable me to reuse the save code?