My current code is something like this (on .aspx
file):
string type = Request.Params["type"];
string param1= Request.Params["param1"];
string param2= Request.Params["param2"];
string param3= Request.Params["param3"];
ReportParams parameters = new ReportParams(param1, param2, param3);
switch (type){
case "Report1":
report = new Report1(parameters);
break;
case "Report2":
report = new Report2(parameters);
break;
case "Report3":
report = new Report3(parameters);
break;
//and 200++ more
default:
break;
}
All reports object accept same object parameter, which is ReportParams
This code working fine, but since I have more than 200 report object to check/compare, I believe this is not the efficient way. plus, it is difficult to maintain in the future.
How can I cast to object with constructor? Can Reflection do this?