| 用System.Web.Caching.Cache保存数据类的缓存 |
| 用System.Web.Caching.Cache保存数据类的缓存 | ||
| 作者:YesHack.… 文章来源:YesHack.Com 更新时间:2006-7-14 7:15:07 【字体:小 大】 | ||
{ public static IDataProvider Instance() { //use the cache because the reflection used later is expensive Cache cache = System.Web.HttpContext.Current.Cache; if ( cache["IDataProvider"] == null ) (NameValueCollection)ConfigurationSettings.GetConfig("appSettings"); String assemblyPath = context[prefix + "DataProviderAssemblyPath"]; "DataProviderClassName"]; // assemblyPath presented in virtual form, must convert to physical path HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath + "/bin/" + assemblyPath); // Uuse reflection to store the constructor of the class that implements IWebForumDataProvider assemblyPath).GetType( className ).GetConstructor(new Type[0]), new CacheDependency( assemblyPath ) ); // could not locate DLL file Could not locate file: <code>" + assemblyPath + "</code> or could not locate class <code>" + className + "</code> in file."); ((ConstructorInfo)cache["IDataProvider"]).Invoke(null) ); |
||
|
||
| 教程录入:YesHack.Com 责任编辑:YesHack.Com | ||
您现在的位置: