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 abstract class _Company
{
public abstract List<Personel> GetPersonel();
public abstract List<Prim> GetPrim();
public abstract List<Finans> GetFinans();
}
public abstract class _Radyoloji
{
public abstract List<string> GetRadyoloji();
}
public abstract class _Satis
{
public abstract List<string> GetSatis();
}
public abstract class _Muayene
{
public abstract List<string> GetMuayene();
}
public class Company: _Company
{
public override List<Personel> GetPersonel()
{
throw new NotImplementedException();
}
public override List<Prim> GetPrim()
{
throw new NotImplementedException();
}
public override List<Finans> GetFinans()
{
throw new NotImplementedException();
}
}
public class Radyoloji : _Radyoloji
{
public override List<string> GetRadyoloji()
{
throw new NotImplementedException();
}
}
public class Satis : _Satis
{
public override List<string> GetSatis()
{
throw new NotImplementedException();
}
}
public class Muayene : _Muayene
{
public override List<string> GetMuayene()
{
throw new NotImplementedException();
}
}
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<Personel> GetPersonel()
{
GenoTipController controller = new GenoTipController();
_Company company = controller.GenerateCompany(DataModelType.Company);
return company.GetPersonel();
}
}
public enum DataModelType
{
Radyoloji,
Satis,
Muayene,
Company
}
}
if use oleksiy.t method :
public class GenoTipController
{
public object CreateByEnum(DataModelType modeltype)
{
string enumText = modeltype.ToString(); // will return for example "Company"
Type classType = Type.GetType(enumText); // the Type for Company class
object t = Activator.CreateInstance(classType); // create an instance of Company class
return t;
}
}
public class CompanyView
{
public static List<Personel> GetPersonel()
{
GenoTipController controller = new GenoTipController();
_Company company = controller.CreateByEnum(DataModelType.Company);
return company.GetPersonel();
}
}
public enum DataModelType
{
Radyoloji,
Satis,
Muayene,
Company
}