I think the below code says it all.
// Example A
switch (id)
{
case 1:
return await Callout<ClassA>(a, b, c, d, e, f, g, h, i, j, k, l, m);
case 2:
return await Callout<ClassB>(a, b, c, d, e, f, g, h, i, j, k, l, m);
case 3:
return await Callout<ClassC>(a, b, c, d, e, f, g, h, i, j, k, l, m);
case 4:
return await Callout<ClassD>(a, b, c, d, e, f, g, h, i, j, k, l, m);
...
}
// Example B
MagicClassHolder x;
switch (id)
{
case 1:
set x = ClassA;
case 2:
set x = ClassB;
case 3:
set x = ClassC;
case 4:
set x = ClassD;
...
}
return await Callout<x>(a, b, c, d, e, f, g, h, i, j, k, l, m);
Example A is already running fine in my code. And I gather Example B is not feasible. (Though I'd love to be wrong.) However Example B is easier to read. Are there obvious tricks that would improve on what I have in Example A and make it more readable à la Example B?