注意存在特定的关键字Implements用于指定这个特殊的Dispose()方法实现必需的IHttpModuleDispose方法如同所有HttpModules所需要的那样现在将其与Init()方法中的代码进行比较
Public Sub Init(ByVal context As SystemWebHttpApplication) Implements SystemWebIHttpModuleInit
AddHandler contextPreRequestHandlerExecute New EventHandler(AddressOf app_PreRequestHandlerExecute)
End Sub
在这个方法的顶部是Implements语句(由于页面宽度约束在打印出来的书籍中该语句换行到下一行)在这种情况中的Init()方法实现必需的IHttpModuleInit方法
在这儿该方法自身中的代码最初看起来稍微有点复杂只有一行需要考虑该行声明一个新的事件处理程序每次当前的上下文处于请求生存期中的PreRequestHandlerExecute阶段时运行该事件处理程序以纯英语的方式来看这是相当早期的请求阶段!这行代码意味着每次适当的事件激活时可以添加将进行处理的事件处理程序这个事件处理程序是在代码中声明的最后一个方法
Private Sub app_PreRequestHandlerExecute(ByVal Sender As Object ByVal E As EventArgs)
HttpContextCurrentTraceWrite(ThemeModule app_PreRequestHandlerExecute)
Dim p As Page = TryCast(HttpContextCurrentHandler Page)
If p IsNot Nothing Then
Dim pb As ProfileCommon = DirectCast(HttpContextCurrentProfile ProfileCommon)
pTheme = pbTheme
End If
End Sub
End Class
End Namespace
[] [] [] [] [] []