ASP.NET Portal starter Kit ----之页面配置文件
前一阵子抽了一些时间看了一下缩水版的DNN(starter kit)---- [从二十四画生那里请教的DNN的学习方法]。
其中portal的用户配置文件portalCfg.xml还有该文件的操作类portalCfg.vb是实现灵活页面布局的关键。一开始觉得写操作类的portalCfg.vb文件很难,而且那么长的代码文件差不多2k多行,仔细看portalCfg.vb文件的头部包含这样的注释 :
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.0.3705.209
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.0.3705.209
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
因为对XML了解不深,查找一些资料才发现原来portalCfg.vb文件根本不用手写,用生成就可以了,无论是xml或config文件都可。
随便找简单的几行代码先试试
建立一个sample.xml 代码如下
<?xml version="1.0" encoding="utf-8" ?>
<SiteConfiguration>
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
</SiteConfiguration>
<SiteConfiguration>
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
</SiteConfiguration>
然后在VS2003 里面 按mouse右键 --〉生成架构 你会发现项目中会多出一个 sample.xsd的文件而且你的portalCfg.xml的文件也变成如下
<?xml version="1.0" encoding="utf-8"?>
<SiteConfiguration xmlns="http://tempuri.org/sample.xsd">
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
</SiteConfiguration>
<SiteConfiguration xmlns="http://tempuri.org/sample.xsd">
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
</SiteConfiguration>
portal.xsd的代码
<?xml version="1.0"?>
<xs:schema id="SiteConfiguration" targetNamespace="http://tempuri.org/sample.xsd" xmlns:mstns="http://tempuri.org/sample.xsd" xmlns="http://tempuri.org/sample.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="SiteConfiguration" msdata:IsDataSet="true" msdata:Locale="zh-CN" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Module">
<xs:complexType>
<xs:attribute name="ModuleId" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleTitle" form="unqualified" type="xs:string" />
<xs:attribute name="EditRoles" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleDefId" form="unqualified" type="xs:string" />
<xs:attribute name="PaneName" form="unqualified" type="xs:string" />
<xs:attribute name="CacheTimeout" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleOrder" form="unqualified" type="xs:string" />
<xs:attribute name="ShowMobile" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema id="SiteConfiguration" targetNamespace="http://tempuri.org/sample.xsd" xmlns:mstns="http://tempuri.org/sample.xsd" xmlns="http://tempuri.org/sample.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="SiteConfiguration" msdata:IsDataSet="true" msdata:Locale="zh-CN" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Module">
<xs:complexType>
<xs:attribute name="ModuleId" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleTitle" form="unqualified" type="xs:string" />
<xs:attribute name="EditRoles" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleDefId" form="unqualified" type="xs:string" />
<xs:attribute name="PaneName" form="unqualified" type="xs:string" />
<xs:attribute name="CacheTimeout" form="unqualified" type="xs:string" />
<xs:attribute name="ModuleOrder" form="unqualified" type="xs:string" />
<xs:attribute name="ShowMobile" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
然后打开sample.xsd文件 --〉在数据集模式下面按mouse右键--〉生成数据集 sample.vb代码就出来了。
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.573
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serialization
Imports System.Xml
<Serializable(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Diagnostics.DebuggerStepThrough(), _
System.ComponentModel.ToolboxItem(true)> _
Public Class SiteConfiguration
Inherits DataSet
Private table_Module As _ModuleDataTable
Public Sub New()
MyBase.New
Me.InitClass
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New
Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(System.String)),String)
If (Not (strSchema) Is Nothing) Then
Dim ds As DataSet = New DataSet
ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(strSchema)))
If (Not (ds.Tables("Module")) Is Nothing) Then
Me.Tables.Add(New _ModuleDataTable(ds.Tables("Module")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
Else
Me.InitClass
End If
Me.GetSerializationData(info, context)
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
<System.ComponentModel.Browsable(false), _
System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)> _
Public ReadOnly Property _Module As _ModuleDataTable
Get
Return Me.table_Module
End Get
End Property
Public Overrides Function Clone() As DataSet
Dim cln As SiteConfiguration = CType(MyBase.Clone,SiteConfiguration)
cln.InitVars
Return cln
End Function
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
Protected Overrides Function ShouldSerializeRelations() As Boolean
Return false
End Function
Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
Me.Reset
Dim ds As DataSet = New DataSet
ds.ReadXml(reader)
If (Not (ds.Tables("Module")) Is Nothing) Then
Me.Tables.Add(New _ModuleDataTable(ds.Tables("Module")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
End Sub
Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
stream.Position = 0
Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
End Function
Friend Sub InitVars()
Me.table_Module = CType(Me.Tables("Module"),_ModuleDataTable)
If (Not (Me.table_Module) Is Nothing) Then
Me.table_Module.InitVars
End If
End Sub
Private Sub InitClass()
Me.DataSetName = "SiteConfiguration"
Me.Prefix = ""
Me.Namespace = "http://tempuri.org/sample.xsd"
Me.Locale = New System.Globalization.CultureInfo("zh-CN")
Me.CaseSensitive = false
Me.EnforceConstraints = false
Me.table_Module = New _ModuleDataTable
Me.Tables.Add(Me.table_Module)
End Sub
Private Function ShouldSerialize_Module() As Boolean
Return false
End Function
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
Me.InitVars
End If
End Sub
Public Delegate Sub _ModuleRowChangeEventHandler(ByVal sender As Object, ByVal e As _ModuleRowChangeEvent)
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private columnModuleId As DataColumn
Private columnModuleTitle As DataColumn
Private columnEditRoles As DataColumn
Private columnModuleDefId As DataColumn
Private columnPaneName As DataColumn
Private columnCacheTimeout As DataColumn
Private columnModuleOrder As DataColumn
Private columnShowMobile As DataColumn
Friend Sub New()
MyBase.New("Module")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Browsable(false)> _
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property ModuleIdColumn As DataColumn
Get
Return Me.columnModuleId
End Get
End Property
Friend ReadOnly Property ModuleTitleColumn As DataColumn
Get
Return Me.columnModuleTitle
End Get
End Property
Friend ReadOnly Property EditRolesColumn As DataColumn
Get
Return Me.columnEditRoles
End Get
End Property
Friend ReadOnly Property ModuleDefIdColumn As DataColumn
Get
Return Me.columnModuleDefId
End Get
End Property
Friend ReadOnly Property PaneNameColumn As DataColumn
Get
Return Me.columnPaneName
End Get
End Property
Friend ReadOnly Property CacheTimeoutColumn As DataColumn
Get
Return Me.columnCacheTimeout
End Get
End Property
Friend ReadOnly Property ModuleOrderColumn As DataColumn
Get
Return Me.columnModuleOrder
End Get
End Property
Friend ReadOnly Property ShowMobileColumn As DataColumn
Get
Return Me.columnShowMobile
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As _ModuleRow
Get
Return CType(Me.Rows(index),_ModuleRow)
End Get
End Property
Public Event _ModuleRowChanged As _ModuleRowChangeEventHandler
Public Event _ModuleRowChanging As _ModuleRowChangeEventHandler
Public Event _ModuleRowDeleted As _ModuleRowChangeEventHandler
Public Event _ModuleRowDeleting As _ModuleRowChangeEventHandler
Public Overloads Sub Add_ModuleRow(ByVal row As _ModuleRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function Add_ModuleRow(ByVal ModuleId As String, ByVal ModuleTitle As String, ByVal EditRoles As String, ByVal ModuleDefId As String, ByVal PaneName As String, ByVal CacheTimeout As String, ByVal ModuleOrder As String, ByVal ShowMobile As String) As _ModuleRow
Dim row_ModuleRow As _ModuleRow = CType(Me.NewRow,_ModuleRow)
row_ModuleRow.ItemArray = New Object() {ModuleId, ModuleTitle, EditRoles, ModuleDefId, PaneName, CacheTimeout, ModuleOrder, ShowMobile}
Me.Rows.Add(row_ModuleRow)
Return row_ModuleRow
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As _ModuleDataTable = CType(MyBase.Clone,_ModuleDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New _ModuleDataTable
End Function
Friend Sub InitVars()
Me.columnModuleId = Me.Columns("ModuleId")
Me.columnModuleTitle = Me.Columns("ModuleTitle")
Me.columnEditRoles = Me.Columns("EditRoles")
Me.columnModuleDefId = Me.Columns("ModuleDefId")
Me.columnPaneName = Me.Columns("PaneName")
Me.columnCacheTimeout = Me.Columns("CacheTimeout")
Me.columnModuleOrder = Me.Columns("ModuleOrder")
Me.columnShowMobile = Me.Columns("ShowMobile")
End Sub
Private Sub InitClass()
Me.columnModuleId = New DataColumn("ModuleId", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleId)
Me.columnModuleTitle = New DataColumn("ModuleTitle", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleTitle)
Me.columnEditRoles = New DataColumn("EditRoles", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnEditRoles)
Me.columnModuleDefId = New DataColumn("ModuleDefId", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleDefId)
Me.columnPaneName = New DataColumn("PaneName", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnPaneName)
Me.columnCacheTimeout = New DataColumn("CacheTimeout", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnCacheTimeout)
Me.columnModuleOrder = New DataColumn("ModuleOrder", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleOrder)
Me.columnShowMobile = New DataColumn("ShowMobile", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnShowMobile)
Me.columnModuleId.Namespace = ""
Me.columnModuleTitle.Namespace = ""
Me.columnEditRoles.Namespace = ""
Me.columnModuleDefId.Namespace = ""
Me.columnPaneName.Namespace = ""
Me.columnCacheTimeout.Namespace = ""
Me.columnModuleOrder.Namespace = ""
Me.columnShowMobile.Namespace = ""
End Sub
Public Function New_ModuleRow() As _ModuleRow
Return CType(Me.NewRow,_ModuleRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New _ModuleRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(_ModuleRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me._ModuleRowChangedEvent) Is Nothing) Then
RaiseEvent _ModuleRowChanged(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me._ModuleRowChangingEvent) Is Nothing) Then
RaiseEvent _ModuleRowChanging(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me._ModuleRowDeletedEvent) Is Nothing) Then
RaiseEvent _ModuleRowDeleted(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me._ModuleRowDeletingEvent) Is Nothing) Then
RaiseEvent _ModuleRowDeleting(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Public Sub Remove_ModuleRow(ByVal row As _ModuleRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleRow
Inherits DataRow
Private table_Module As _ModuleDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.table_Module = CType(Me.Table,_ModuleDataTable)
End Sub
Public Property ModuleId As String
Get
Try
Return CType(Me(Me.table_Module.ModuleIdColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleIdColumn) = value
End Set
End Property
Public Property ModuleTitle As String
Get
Try
Return CType(Me(Me.table_Module.ModuleTitleColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleTitleColumn) = value
End Set
End Property
Public Property EditRoles As String
Get
Try
Return CType(Me(Me.table_Module.EditRolesColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.EditRolesColumn) = value
End Set
End Property
Public Property ModuleDefId As String
Get
Try
Return CType(Me(Me.table_Module.ModuleDefIdColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleDefIdColumn) = value
End Set
End Property
Public Property PaneName As String
Get
Try
Return CType(Me(Me.table_Module.PaneNameColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.PaneNameColumn) = value
End Set
End Property
Public Property CacheTimeout As String
Get
Try
Return CType(Me(Me.table_Module.CacheTimeoutColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.CacheTimeoutColumn) = value
End Set
End Property
Public Property ModuleOrder As String
Get
Try
Return CType(Me(Me.table_Module.ModuleOrderColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleOrderColumn) = value
End Set
End Property
Public Property ShowMobile As String
Get
Try
Return CType(Me(Me.table_Module.ShowMobileColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ShowMobileColumn) = value
End Set
End Property
Public Function IsModuleIdNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleIdColumn)
End Function
Public Sub SetModuleIdNull()
Me(Me.table_Module.ModuleIdColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleTitleNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleTitleColumn)
End Function
Public Sub SetModuleTitleNull()
Me(Me.table_Module.ModuleTitleColumn) = System.Convert.DBNull
End Sub
Public Function IsEditRolesNull() As Boolean
Return Me.IsNull(Me.table_Module.EditRolesColumn)
End Function
Public Sub SetEditRolesNull()
Me(Me.table_Module.EditRolesColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleDefIdNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleDefIdColumn)
End Function
Public Sub SetModuleDefIdNull()
Me(Me.table_Module.ModuleDefIdColumn) = System.Convert.DBNull
End Sub
Public Function IsPaneNameNull() As Boolean
Return Me.IsNull(Me.table_Module.PaneNameColumn)
End Function
Public Sub SetPaneNameNull()
Me(Me.table_Module.PaneNameColumn) = System.Convert.DBNull
End Sub
Public Function IsCacheTimeoutNull() As Boolean
Return Me.IsNull(Me.table_Module.CacheTimeoutColumn)
End Function
Public Sub SetCacheTimeoutNull()
Me(Me.table_Module.CacheTimeoutColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleOrderNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleOrderColumn)
End Function
Public Sub SetModuleOrderNull()
Me(Me.table_Module.ModuleOrderColumn) = System.Convert.DBNull
End Sub
Public Function IsShowMobileNull() As Boolean
Return Me.IsNull(Me.table_Module.ShowMobileColumn)
End Function
Public Sub SetShowMobileNull()
Me(Me.table_Module.ShowMobileColumn) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleRowChangeEvent
Inherits EventArgs
Private eventRow As _ModuleRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As _ModuleRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As _ModuleRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.573
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serialization
Imports System.Xml
<Serializable(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Diagnostics.DebuggerStepThrough(), _
System.ComponentModel.ToolboxItem(true)> _
Public Class SiteConfiguration
Inherits DataSet
Private table_Module As _ModuleDataTable
Public Sub New()
MyBase.New
Me.InitClass
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New
Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(System.String)),String)
If (Not (strSchema) Is Nothing) Then
Dim ds As DataSet = New DataSet
ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(strSchema)))
If (Not (ds.Tables("Module")) Is Nothing) Then
Me.Tables.Add(New _ModuleDataTable(ds.Tables("Module")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
Else
Me.InitClass
End If
Me.GetSerializationData(info, context)
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
<System.ComponentModel.Browsable(false), _
System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)> _
Public ReadOnly Property _Module As _ModuleDataTable
Get
Return Me.table_Module
End Get
End Property
Public Overrides Function Clone() As DataSet
Dim cln As SiteConfiguration = CType(MyBase.Clone,SiteConfiguration)
cln.InitVars
Return cln
End Function
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
Protected Overrides Function ShouldSerializeRelations() As Boolean
Return false
End Function
Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
Me.Reset
Dim ds As DataSet = New DataSet
ds.ReadXml(reader)
If (Not (ds.Tables("Module")) Is Nothing) Then
Me.Tables.Add(New _ModuleDataTable(ds.Tables("Module")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
End Sub
Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
stream.Position = 0
Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
End Function
Friend Sub InitVars()
Me.table_Module = CType(Me.Tables("Module"),_ModuleDataTable)
If (Not (Me.table_Module) Is Nothing) Then
Me.table_Module.InitVars
End If
End Sub
Private Sub InitClass()
Me.DataSetName = "SiteConfiguration"
Me.Prefix = ""
Me.Namespace = "http://tempuri.org/sample.xsd"
Me.Locale = New System.Globalization.CultureInfo("zh-CN")
Me.CaseSensitive = false
Me.EnforceConstraints = false
Me.table_Module = New _ModuleDataTable
Me.Tables.Add(Me.table_Module)
End Sub
Private Function ShouldSerialize_Module() As Boolean
Return false
End Function
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
Me.InitVars
End If
End Sub
Public Delegate Sub _ModuleRowChangeEventHandler(ByVal sender As Object, ByVal e As _ModuleRowChangeEvent)
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private columnModuleId As DataColumn
Private columnModuleTitle As DataColumn
Private columnEditRoles As DataColumn
Private columnModuleDefId As DataColumn
Private columnPaneName As DataColumn
Private columnCacheTimeout As DataColumn
Private columnModuleOrder As DataColumn
Private columnShowMobile As DataColumn
Friend Sub New()
MyBase.New("Module")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Browsable(false)> _
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property ModuleIdColumn As DataColumn
Get
Return Me.columnModuleId
End Get
End Property
Friend ReadOnly Property ModuleTitleColumn As DataColumn
Get
Return Me.columnModuleTitle
End Get
End Property
Friend ReadOnly Property EditRolesColumn As DataColumn
Get
Return Me.columnEditRoles
End Get
End Property
Friend ReadOnly Property ModuleDefIdColumn As DataColumn
Get
Return Me.columnModuleDefId
End Get
End Property
Friend ReadOnly Property PaneNameColumn As DataColumn
Get
Return Me.columnPaneName
End Get
End Property
Friend ReadOnly Property CacheTimeoutColumn As DataColumn
Get
Return Me.columnCacheTimeout
End Get
End Property
Friend ReadOnly Property ModuleOrderColumn As DataColumn
Get
Return Me.columnModuleOrder
End Get
End Property
Friend ReadOnly Property ShowMobileColumn As DataColumn
Get
Return Me.columnShowMobile
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As _ModuleRow
Get
Return CType(Me.Rows(index),_ModuleRow)
End Get
End Property
Public Event _ModuleRowChanged As _ModuleRowChangeEventHandler
Public Event _ModuleRowChanging As _ModuleRowChangeEventHandler
Public Event _ModuleRowDeleted As _ModuleRowChangeEventHandler
Public Event _ModuleRowDeleting As _ModuleRowChangeEventHandler
Public Overloads Sub Add_ModuleRow(ByVal row As _ModuleRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function Add_ModuleRow(ByVal ModuleId As String, ByVal ModuleTitle As String, ByVal EditRoles As String, ByVal ModuleDefId As String, ByVal PaneName As String, ByVal CacheTimeout As String, ByVal ModuleOrder As String, ByVal ShowMobile As String) As _ModuleRow
Dim row_ModuleRow As _ModuleRow = CType(Me.NewRow,_ModuleRow)
row_ModuleRow.ItemArray = New Object() {ModuleId, ModuleTitle, EditRoles, ModuleDefId, PaneName, CacheTimeout, ModuleOrder, ShowMobile}
Me.Rows.Add(row_ModuleRow)
Return row_ModuleRow
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As _ModuleDataTable = CType(MyBase.Clone,_ModuleDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New _ModuleDataTable
End Function
Friend Sub InitVars()
Me.columnModuleId = Me.Columns("ModuleId")
Me.columnModuleTitle = Me.Columns("ModuleTitle")
Me.columnEditRoles = Me.Columns("EditRoles")
Me.columnModuleDefId = Me.Columns("ModuleDefId")
Me.columnPaneName = Me.Columns("PaneName")
Me.columnCacheTimeout = Me.Columns("CacheTimeout")
Me.columnModuleOrder = Me.Columns("ModuleOrder")
Me.columnShowMobile = Me.Columns("ShowMobile")
End Sub
Private Sub InitClass()
Me.columnModuleId = New DataColumn("ModuleId", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleId)
Me.columnModuleTitle = New DataColumn("ModuleTitle", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleTitle)
Me.columnEditRoles = New DataColumn("EditRoles", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnEditRoles)
Me.columnModuleDefId = New DataColumn("ModuleDefId", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleDefId)
Me.columnPaneName = New DataColumn("PaneName", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnPaneName)
Me.columnCacheTimeout = New DataColumn("CacheTimeout", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnCacheTimeout)
Me.columnModuleOrder = New DataColumn("ModuleOrder", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnModuleOrder)
Me.columnShowMobile = New DataColumn("ShowMobile", GetType(System.String), Nothing, System.Data.MappingType.Attribute)
Me.Columns.Add(Me.columnShowMobile)
Me.columnModuleId.Namespace = ""
Me.columnModuleTitle.Namespace = ""
Me.columnEditRoles.Namespace = ""
Me.columnModuleDefId.Namespace = ""
Me.columnPaneName.Namespace = ""
Me.columnCacheTimeout.Namespace = ""
Me.columnModuleOrder.Namespace = ""
Me.columnShowMobile.Namespace = ""
End Sub
Public Function New_ModuleRow() As _ModuleRow
Return CType(Me.NewRow,_ModuleRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New _ModuleRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(_ModuleRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me._ModuleRowChangedEvent) Is Nothing) Then
RaiseEvent _ModuleRowChanged(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me._ModuleRowChangingEvent) Is Nothing) Then
RaiseEvent _ModuleRowChanging(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me._ModuleRowDeletedEvent) Is Nothing) Then
RaiseEvent _ModuleRowDeleted(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me._ModuleRowDeletingEvent) Is Nothing) Then
RaiseEvent _ModuleRowDeleting(Me, New _ModuleRowChangeEvent(CType(e.Row,_ModuleRow), e.Action))
End If
End Sub
Public Sub Remove_ModuleRow(ByVal row As _ModuleRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleRow
Inherits DataRow
Private table_Module As _ModuleDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.table_Module = CType(Me.Table,_ModuleDataTable)
End Sub
Public Property ModuleId As String
Get
Try
Return CType(Me(Me.table_Module.ModuleIdColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleIdColumn) = value
End Set
End Property
Public Property ModuleTitle As String
Get
Try
Return CType(Me(Me.table_Module.ModuleTitleColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleTitleColumn) = value
End Set
End Property
Public Property EditRoles As String
Get
Try
Return CType(Me(Me.table_Module.EditRolesColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.EditRolesColumn) = value
End Set
End Property
Public Property ModuleDefId As String
Get
Try
Return CType(Me(Me.table_Module.ModuleDefIdColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleDefIdColumn) = value
End Set
End Property
Public Property PaneName As String
Get
Try
Return CType(Me(Me.table_Module.PaneNameColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.PaneNameColumn) = value
End Set
End Property
Public Property CacheTimeout As String
Get
Try
Return CType(Me(Me.table_Module.CacheTimeoutColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.CacheTimeoutColumn) = value
End Set
End Property
Public Property ModuleOrder As String
Get
Try
Return CType(Me(Me.table_Module.ModuleOrderColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ModuleOrderColumn) = value
End Set
End Property
Public Property ShowMobile As String
Get
Try
Return CType(Me(Me.table_Module.ShowMobileColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.table_Module.ShowMobileColumn) = value
End Set
End Property
Public Function IsModuleIdNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleIdColumn)
End Function
Public Sub SetModuleIdNull()
Me(Me.table_Module.ModuleIdColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleTitleNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleTitleColumn)
End Function
Public Sub SetModuleTitleNull()
Me(Me.table_Module.ModuleTitleColumn) = System.Convert.DBNull
End Sub
Public Function IsEditRolesNull() As Boolean
Return Me.IsNull(Me.table_Module.EditRolesColumn)
End Function
Public Sub SetEditRolesNull()
Me(Me.table_Module.EditRolesColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleDefIdNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleDefIdColumn)
End Function
Public Sub SetModuleDefIdNull()
Me(Me.table_Module.ModuleDefIdColumn) = System.Convert.DBNull
End Sub
Public Function IsPaneNameNull() As Boolean
Return Me.IsNull(Me.table_Module.PaneNameColumn)
End Function
Public Sub SetPaneNameNull()
Me(Me.table_Module.PaneNameColumn) = System.Convert.DBNull
End Sub
Public Function IsCacheTimeoutNull() As Boolean
Return Me.IsNull(Me.table_Module.CacheTimeoutColumn)
End Function
Public Sub SetCacheTimeoutNull()
Me(Me.table_Module.CacheTimeoutColumn) = System.Convert.DBNull
End Sub
Public Function IsModuleOrderNull() As Boolean
Return Me.IsNull(Me.table_Module.ModuleOrderColumn)
End Function
Public Sub SetModuleOrderNull()
Me(Me.table_Module.ModuleOrderColumn) = System.Convert.DBNull
End Sub
Public Function IsShowMobileNull() As Boolean
Return Me.IsNull(Me.table_Module.ShowMobileColumn)
End Function
Public Sub SetShowMobileNull()
Me(Me.table_Module.ShowMobileColumn) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class _ModuleRowChangeEvent
Inherits EventArgs
Private eventRow As _ModuleRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As _ModuleRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As _ModuleRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
这样的话就方便了。用这种方法重新生成portalCfg.vb 发现生成的代码也只比原来的少了几个简单的方法而已。 好了也算是学习DNN的一个小小的收获。贴出来如有不妥请大家指教。
相关链接:
ASP.NET Portal starter Kit ----重构DAL
asp.net Portal Starter kit----改造Portal的Html文本编辑器