一 、配置项
<add key="DalPath" value="Company.Project.BLL" />
<add key="DalValue" value="ControllerManager" />
二、反射创建BLL管理控制器
public static ControllerManager Instance()
{
if (bllManager == null)
{
string path = ConfigurationManager.AppSettings["DalPath"];
string value = ConfigurationManager.AppSettings["DalValue"];
Type type = Assembly.Load(path).GetType(path + "." +value);
ConstructorInfo ci = type.GetConstructor(System.Type.EmptyTypes);
bllManager = (ControllerManager)ci.Invoke(null);
}
return bllManager;
}
三、BLL层管理控制器
public class ControllerManager
{
public ABLL aBLL
{
get
{
return new ABLL();
}
}
public BBLL bBLL
{
get
{
return new BBLL();
}
}
}