MyController class must produce class according to the enum type.
Posted
by programmerist
on Stack Overflow
See other posts from Stack Overflow
or by programmerist
Published on 2010-04-16T07:24:23Z
Indexed on
2010/04/16
7:53 UTC
Read the original article
Hit count: 267
GenoTipController must produce class according to the enum type. i have 3 class: _Company,_Muayene,_Radyoloji. Also i have CompanyView Class GetPersonel method. if you look GenoTipController my codes need refactoring. Can you understand me? i need a class according to ewnum type must me produce class. For example; case DataModelType.Radyoloji it must return radyoloji= new Radyoloji . Everything must be one switch case?
public class GenoTipController
{
public _Company GenerateCompany(DataModelType modeltype)
{
_Company company = null;
switch (modeltype)
{
case DataModelType.Radyoloji:
break;
case DataModelType.Satis:
break;
case DataModelType.Muayene:
break;
case DataModelType.Company:
company = new Company();
break;
default:
break;
}
return company;
}
public _Muayene GenerateMuayene(DataModelType modeltype)
{
_Muayene muayene = null;
switch (modeltype)
{
case DataModelType.Radyoloji:
break;
case DataModelType.Satis:
break;
case DataModelType.Muayene:
muayene = new Muayene();
break;
case DataModelType.Company:
break;
default:
break;
}
return muayene;
}
public _Radyoloji GenerateRadyoloji(DataModelType modeltype)
{
_Radyoloji radyoloji = null;
switch (modeltype)
{
case DataModelType.Radyoloji:
radyoloji = new Radyoloji();
break;
case DataModelType.Satis:
break;
case DataModelType.Muayene:
break;
case DataModelType.Company:
break;
default:
break;
}
return radyoloji;
}
}
public class CompanyView
{
public static List GetPersonel()
{
GenoTipController controller = new GenoTipController();
_Company company = controller.GenerateCompany(DataModelType.Company);
return company.GetPersonel();
}
}
public enum DataModelType
{
Radyoloji,
Satis,
Muayene,
Company
}
}
© Stack Overflow or respective owner