I would say the easiest solution would be to write one generic function that takes the 'type' as a parameter. Even if it means having the switch case within the function itself, just have a mix of generic and non-generic code in the function. I would just create an enum for the different types.