internal static void AttachEvents(HttpApplication app) { HttpApplicationFactory factory = theFactory; Hashtable possibleEvents = factory.GetApplicationTypeEvents(app); foreach (string key in possibleEvents.Keys) { int pos = key.IndexOf('_'); string moduleName = key.Substring(0, pos); object target; if (moduleName == "Application") { target = app; } else { target = app.Modules [moduleName]; if (target == null) { continue; } } string eventName = key.Substring(pos + 1); EventInfo evt = target.GetType().GetEvent(eventName); if (evt == null) { continue; } string usualName = moduleName + "_" + eventName; object methodData = possibleEvents [usualName]; if (methodData == null) { continue; } if (eventName == "End" && moduleName == "Session") { Interlocked.CompareExchange(ref factory.session_end, methodData, null); continue; } if (methodData is MethodInfo) { factory.AddHandler(evt, target, app, (MethodInfo)methodData); continue; } ArrayList list = (ArrayList)methodData; foreach (MethodInfo method in list) { factory.AddHandler(evt, target, app, method); } } }