A
Andrus
I use switch statement to create Generic list for combobox:
using EntityExtension;
public static class ComboPickList {
public static object GetObjectPickList(string entityClassName) {
switch (entityClassName) {
case "Customer":
return new List<Customer>();
case "Item":
return new List<Item>();
....
}}}
All entity classes are defined in same assembly in EntityExtension
namespace.
there are approx 40 entity classes so switch is long.
More importantly, some entityClassName 's are not known at design time
because may be defined by user at runtime.
How to refactor this method code so it allows to use any entityClassName
without adding it to case label ?
Can I use MakeGenericType() or reflection ?
Andrus.
using EntityExtension;
public static class ComboPickList {
public static object GetObjectPickList(string entityClassName) {
switch (entityClassName) {
case "Customer":
return new List<Customer>();
case "Item":
return new List<Item>();
....
}}}
All entity classes are defined in same assembly in EntityExtension
namespace.
there are approx 40 entity classes so switch is long.
More importantly, some entityClassName 's are not known at design time
because may be defined by user at runtime.
How to refactor this method code so it allows to use any entityClassName
without adding it to case label ?
Can I use MakeGenericType() or reflection ?
Andrus.