110,549
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// This class is implemented following the Abstract Factory pattern to create the BLL implementation
/// specified from the configuration file
/// </summary>
public sealed class DataAccess
{
// Look up the BLL implementation we should be using
private static readonly string path = "*****.BLL";
private static readonly Assembly bllAssembly = null;
static DataAccess()
{
bllAssembly = Assembly.Load(path);
}
private DataAccess() { }
/// <summary>
/// 创建业务逻辑对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static T GetBll<T>()
{
Type type = typeof(T);
return (T)bllAssembly.CreateInstance(type.Namespace.Replace("IBLL", "BLL") + "." + type.Name.Substring(1));
}
}