using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EfTestFactory
{
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 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 AntsController
{
static Dictionary<DataModelType, Func<object>> s_creators =
new Dictionary<DataModelType, Func<object>>()
{
{ DataModelType.Radyoloji, () => new _Radyoloji() },
{ DataModelType.Company, () => new _Company() },
{ DataModelType.Muayene, () => new _Muayene() },
{ DataModelType.Satis, () => new _Satis() },
};
public object CreateByEnum(DataModelType modeltype)
{
return s_creators[modeltype]();
}
}
public class CompanyView
{
public static List<Personel> GetPersonel()
{
GenoTipController controller = new GenoTipController();
_Company company = controller.CreateByEnum(DataModelType.Company) as _Company;
return company.GetPersonel();
}
}
public enum DataModelType
{
Radyoloji,
Satis,
Muayene,
Company
}
}
если я пишу вышеупомянутые коды, я вижу некоторую ошибку: Невозможно создать экземпляр абстрактного класса или интерфейса 'EfTestFactory_Company' Как я могу решить эту проблему? Посмотрите пожалуйста ниже рис. альтернативный текст http://i44.tinypic.com/33wa8tc.png