我正在阅读 .NET4 源代码(可以免费下载它们进行研究),我在 .NET4 的实现中发现了一些奇怪的东西System.Web.Security.FormsAuthenticationModule。
该类声明如下:
public sealed class FormsAuthenticationModule : IHttpModule
whereIHttpModule有两种方法 -Init()和Dispose().
里面OnEnter()有这些行:
// Step 2: Call OnAuthenticate virtual method to create
// an IPrincipal for this request
OnAuthenticate( new FormsAuthenticationEventArgs(context) );
whereOnAuthenticate()声明如下:
// OnAuthenticate: Forms Authentication modules can override
// this method to create a Forms IPrincipal object from
// a WindowsIdentity
private void OnAuthenticate(FormsAuthenticationEventArgs e) {
现在类是sealed,所以不可能继承。也不OnAuthenticate()是virtual,所以我看不出它是如何被覆盖的。
所以看起来这些评论已经过时并且OnAuthenticate()不再可能覆盖。
我有什么不对吗?这段代码可能允许覆盖OnAuthenticate()吗?