温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:中小企业网站系统前台源码(SmallBusinessStarterKit)
当前文件:
SmallBusinessStarterKit/smallbusiness_vb/App_Code/News/News.vb[1K,2009-6-12 11:54:22],打开代码结构图
SmallBusinessStarterKit/smallbusiness_vb/App_Code/News/News.vb[1K,2009-6-12 11:54:22],打开代码结构图1Imports Microsoft.VisualBasic 2
3
Imports System 4
Imports System.Collections.Generic 5
Imports System.Configuration 6
Imports System.Web.Configuration 7
8
_ 9
10
11
'/<summary> 12
'/ class News 13
'/ Provides static functions to access News 14
'/ and serves as abastraction layer between the web Page and 15
'/ actual data providers 16
'/</summary> 17
Public Class News 18
19
Private Shared _isInitialized As Boolean = False 20
Private Shared _provider As NewsProvider 21
Private Shared _providersSection As SmallBusinessDataProvidersSection 22
23
24
' <summary> 25
' Returns provider 26
' </summary> 27
Public Shared ReadOnly Property Provider() As NewsProvider 28
Get 29
Initialize() 30
Return _provider 31
End Get 32
End Property 33
34
35
' <summary> 36
' Returns all news items 37
' </summary> 38
Public Shared Function GetAllNews() As List(Of NewsItem) 39
Return Provider.GetAllNews() 40
End Function 'New 41
42
43
' <summary> 44
' Returns a particular news item 45
' </summary> 46
Public Shared Function GetNewsItem(ByVal newsItemId As String) As NewsItem 47
Return Provider.GetNewsItem(newsItemId) 48
End Function 'GetNewsItem 49
50
' <summary> 51
' Initializes the Provider 52
' </summary> 53
Private Shared Sub Initialize() 54
If Not _isInitialized Then 55
56
_providersSection = ConfigurationManager.GetSection("SmallBusinessDataProviders") ' 57
58
If _providersSection Is Nothing Then 59
Throw New InvalidOperationException(Messages.NewsConfigSectionNotFound) 60
End If 61
62
_provider = ProvidersHelper.InstantiateProvider(_providersSection.NewsProviders(_providersSection.NewsProviderName), GetType(NewsProvider)) 63
64
If _provider Is Nothing Then 65
Throw New InvalidOperationException(Messages.NewsProviderInstantiationError) 66
End If 67
68
_isInitialized = True 69
End If 70
End Sub 'Initialize 71
End Class 'News ' end class








