Asp.net源码专业站
首页->企业网站->中小企业网站系统前台源码(SmallBusinessStarterKit)>>App-Code/Catalog/Catalog.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:中小企业网站系统前台源码(SmallBusinessStarterKit)
当前文件:文件类型 SmallBusinessStarterKit/App_Code/Catalog/Catalog.cs[2K,2009-6-12 11:54:21]打开代码结构图
普通视图
		            
1using System; 2using System.Collections.Generic; 3using System.Configuration; 4using System.Web.Configuration; 5///<summary> 6///Catalog类 7/// 提供静态函数访问产品和分类。作为一个抽象层在Web page和实际的数据提供者之间 8///</summary> 9public static class Catalog 10{ 11 private static bool _isInitialized = false; 12 private static CatalogProvider _provider; 13 private static SmallBusinessDataProvidersSection _providersSection; 14 15 ///<summary> 16 /// 只读属性,返回指定的数据提供者 17 ///</summary> 18 public static CatalogProvider Provider 19 { 20 get 21 { 22 Initialize(); 23 return _provider; 24 } 25 } 26 ///<summary> 27 ///根据指定的分类ID返回产品集合。 28 ///</summary> 29 public static List<Item> GetChildItems(string categoryId) 30 { 31 return Provider.GetChildItems(categoryId); 32 } 33 ///<summary> 34 /// 根据指定的父分类返回子分类集合。 35 ///</summary> 36 public static List<Category> GetChildCategories(string parentCategoryId) 37 { 38 return Provider.GetChildCategories(parentCategoryId); 39 } 40 ///<summary> 41 /// 根据指定的itemId返回产品项 42 ///</summary> 43 public static Item GetItem(string itemId) 44 { 45 return Provider.GetItem(itemId); 46 } 47 /// <summary> 48 /// 基于web.config配置文件,初始化具体的数据提供者,如果指定的提供者不能被 49 /// 实例化,则抛出一个InvalidOperationException异常。 50 /// </summary> 51 //51_a_s_p_x.c_o_m 52 53 private static void Initialize() 54 { 55 //_isInitialized内部使用,如果提供者己经被实例化,就不用再次实例化。这 56 //样可以防止实例化一个提供者多次。 57 if (!_isInitialized) 58 { 59 _providersSection = (ConfigurationManager.GetSection("SmallBusinessDataProviders")) as SmallBusinessDataProvidersSection; 60 if (_providersSection == null) 61 { 62 throw new InvalidOperationException(Messages.ItemConfigNotFound); 63 } 64 //调用ProviderHelper.Instantiateprovider类实例化相应的提供者对象。 65 _provider = ProvidersHelper.InstantiateProvider(_providersSection.CatalogProviders[_providersSection.CatalogProviderName], 66 typeof(CatalogProvider)) as CatalogProvider; 67 //如果不能实例化相应的提供者,则抛出InvalidOperationException异常。 68 if (_provider == null) 69 { 70 throw new InvalidOperationException(Messages.ItemProviderInstantiationError); 71 } 72 _isInitialized = true; 73 } 74 } 75} 76 77
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:中小企业网站系统前台源码(SmallBusinessStarterKit)
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146