首页->企业网站->中小企业网站系统前台源码(SmallBusinessStarterKit)>>smallbusiness_vb/App-Code/Catalog/Catalog.vb>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:中小企业网站系统前台源码(SmallBusinessStarterKit)
当前文件:
SmallBusinessStarterKit/smallbusiness_vb/App_Code/Catalog/Catalog.vb[2K,2009-6-12 11:54:22],打开代码结构图
SmallBusinessStarterKit/smallbusiness_vb/App_Code/Catalog/Catalog.vb[2K,2009-6-12 11:54:22],打开代码结构图1Imports Microsoft.VisualBasic 2
Imports System 3
Imports System.Collections.Generic 4
Imports System.Configuration 5
Imports System.Web.Configuration 6
7
'/<summary> 8
'/ class Catalog 9
'/ Provides static functions to access items & categories 10
'/ and serves as abastraction layer between the web Page and 11
'/ actual data providers 12
'/</summary> 13
Public Class Catalog 14
Private Shared _isInitialized As Boolean = False 15
Private Shared _provider As CatalogProvider 16
Private Shared _providersSection As SmallBusinessDataProvidersSection 17
18
'/<summary> 19
'/ returns the current items data provider 20
'/</summary> 21
Public Shared ReadOnly Property Provider() As CatalogProvider 22
Get 23
Initialize() 24
Return _provider 25
End Get 26
End Property 27
28
29
'<summary> 30
' Returns item belonging to the category having id: 'parentCategoryId' 31
'</summary> 32
Public Shared Function GetChildItems(ByVal categoryId As String) As List(Of Item) 33
34
Return Provider.GetChildItems(categoryId) 35
End Function 36
37
38
'<summary> 39
' Returns subcategories under the category having id: 'parentCategoryId' 40
'</summary> 41
Public Shared Function GetChildCategories(ByVal parentCategoryId As String) As List(Of Category) 42
43
Return Provider.GetChildCategories(parentCategoryId) 44
End Function 45
46
47
'<summary> 48
' Returns an item matching the id 49
'</summary> 50
Public Shared Function GetItem(ByVal itemId As String) As Item 51
Return Provider.GetItem(itemId) 52
End Function 53
54
55
56
'<summary> 57
'Initilizes a concrete data provider based on setting in web.config 58
'InvalidOperationException may be thrown if an actual provider cannot be instantiated 59
'</summary> 60
Private Shared Sub Initialize() 61
If Not _isInitialized Then 62
_providersSection = ConfigurationManager.GetSection("SmallBusinessDataProviders") ' 63
64
If _providersSection Is Nothing Then 65
Throw New InvalidOperationException(Messages.ItemConfigNotFound) 66
End If 67
_provider = ProvidersHelper.InstantiateProvider(_providersSection.CatalogProviders(_providersSection.CatalogProviderName), GetType(CatalogProvider)) 68
69
If _provider Is Nothing Then 70
Throw New InvalidOperationException(Messages.ItemProviderInstantiationError) 71
End If 72
_isInitialized = True 73
End If 74
End Sub 'Initialize 75
End Class 'Catalog 76
77
78








