I'm working with a switch statement that sets certain properties of an object dependent on a case - a new requirement has came in to add a case statement 'All' to essentially execute all the cases to apply all the fields - used in exceptional cases.
I can't really find a nice solution around this, each case statement is only setting 1-2 property values so it wouldn't be worth separating the logic into methods. However, I also don't want to have a load of duplicate code.
var person = new Person(); switch (PersonEnum) { case PersonEnum.Name: person.Name = ... break; case PersonEnum.Age: person.Age = ... break; case PersonEnum.All: person.Name = ... person.Age = ... break; The example code above is a far more simplified version of what I'm dealing with, but the idea still applies.