System.Web.HttpApplicationFactory.GetApplicationTypeEvents C# (CSharp) Method

GetApplicationTypeEvents() private method

private GetApplicationTypeEvents ( System.Web.HttpApplication app ) : Hashtable
app System.Web.HttpApplication
return System.Collections.Hashtable
		Hashtable GetApplicationTypeEvents (HttpApplication app)
		{
			if (have_app_events)
				return app_event_handlers;

			return GetApplicationTypeEvents (app.GetType ());
		}

Same methods

HttpApplicationFactory::GetApplicationTypeEvents ( Type type ) : Hashtable

Usage Example

Example #1
0
        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);
                }
            }
        }