日期:2014-05-18 浏览次数:20444 次
namespace PopForums.Data { public class ClientLoader { public static IPopForumsData Methods() { Cache cache = HttpContext.Current.Cache; if (cache["IPopForumsData"] == null) { if ((ConfigurationSettings.AppSettings["PopForumsDataClass"] == null) || (ConfigurationSettings.AppSettings["PopForumsDataDll"] == null)) // no data layer specified, use the internal one cache.Insert("IPopForumsData", typeof(PopForums.Data.Provider).Module.Assembly .GetType("PopForums.Data SqlClient").GetConstructor(new Type[0])); else { // user has specified an external data layer string assemblyPath = "~\\bin\\" + ConfigurationSettings .AppSettings["PopForumsDataDll"]; string className = ConfigurationSettings.AppSettings["PopForumsDataClass"]; cache.Insert("IPopForumsData", Assembly.LoadFrom(assemblyPath).GetType (className).GetConstructor(new Type[0])); } } return (IPopForumsData)( ((ConstructorInfo)cache["IPopForumsData"]).Invoke(null) ); } } }