web.config中的配置
<!--抽象工厂创建对象的所需的参数-->
<appSettings>
<add key="dalAssmeblyPath" value="Shop.DAL"/>
<add key="nameSpace" value="Shop.DAL"/>
</appSettings>
AbstractFactory类中的代码
public static partial class AbstractFactory
{
private static string dalAssmeblyPath = ConfigurationManager.AppSettings["dalAssmeblyPath"];
private static string nameSpace = ConfigurationManager.AppSettings["nameSpace"];
public static Shop.IDAL.IBookType GetBookTypeDal()
{
string fillName = nameSpace + ".BookType";
Assembly assembly = Assembly.Load(dalAssmeblyPath);
return assembly.CreateInstance(fillName) as Shop.IDAL.IBookType;
}
}