GetModules() public static method

public static GetModules ( System.Web.HttpApplication application ) : IEnumerable
application System.Web.HttpApplication
return IEnumerable
Esempio n. 1
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        public virtual void Init(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            ErrorFilterConfiguration config = (ErrorFilterConfiguration)Configuration.GetSubsection("errorFilter");

            if (config == null)
            {
                return;
            }

            _assertion = config.Assertion;

            foreach (IHttpModule module in HttpModuleRegistry.GetModules(application))
            {
                IExceptionFiltering filtering = module as IExceptionFiltering;

                if (filtering != null)
                {
                    filtering.Filtering += new ExceptionFilterEventHandler(OnErrorModuleFiltering);
                }
            }
        }
Esempio n. 2
0
        private static IList GetAuthorizationHandlers(HttpContext context)
        {
            Debug.Assert(context != null);

            object key      = _authorizationHandlersKey;
            IList  handlers = (IList)context.Items[key];

            if (handlers == null)
            {
                const int capacity = 4;
                ArrayList list     = null;

                HttpApplication application = context.ApplicationInstance;
                if (application is IRequestAuthorizationHandler)
                {
                    list = new ArrayList(capacity);
                    list.Add(application);
                }

                foreach (IHttpModule module in HttpModuleRegistry.GetModules(application))
                {
                    if (module is IRequestAuthorizationHandler)
                    {
                        if (list == null)
                        {
                            list = new ArrayList(capacity);
                        }
                        list.Add(module);
                    }
                }

                context.Items[key] = handlers = ArrayList.ReadOnly(
                    list != null
                    ? list.ToArray(typeof(IRequestAuthorizationHandler))
                    : _zeroAuthorizationHandlers);
            }

            return(handlers);
        }
Esempio n. 3
0
        private static IEnumerable <IRequestAuthorizationHandler> GetAuthorizationHandlers(HttpContextBase context)
        {
            Debug.Assert(context != null);

            var key      = _authorizationHandlersKey;
            var handlers = (IEnumerable <IRequestAuthorizationHandler>)context.Items[key];

            if (handlers == null)
            {
                handlers =
                    from app in new[] { context.ApplicationInstance }
                let mods = HttpModuleRegistry.GetModules(app)
                           select new[] { app }.Concat(from object m in mods select m) into objs
                from obj in objs
                select obj as IRequestAuthorizationHandler into handler
                where handler != null
                select handler;

                context.Items[key] = handlers = Array.AsReadOnly(handlers.ToArray());
            }

            return(handlers);
        }
Esempio n. 4
0
        private static IList <IRequestAuthorizationHandler> GetAuthorizationHandlers(HttpContext context)
        {
            Debug.Assert(context != null);

            object key = _authorizationHandlersKey;
            IList <IRequestAuthorizationHandler> handlers = (IList <IRequestAuthorizationHandler>)context.Items[key];

            if (handlers == null)
            {
                const int capacity = 4;
                List <IRequestAuthorizationHandler> list = new List <IRequestAuthorizationHandler>(capacity);

                HttpApplication application = context.ApplicationInstance;
                IRequestAuthorizationHandler appReqHandler = application as IRequestAuthorizationHandler;
                if (appReqHandler != null)
                {
                    list.Add(appReqHandler);
                }

                foreach (IHttpModule module in HttpModuleRegistry.GetModules(application))
                {
                    IRequestAuthorizationHandler modReqHander = module as IRequestAuthorizationHandler;
                    if (modReqHander != null)
                    {
                        list.Add(modReqHander);
                    }
                }

                if (list != null)
                {
                    context.Items[key] = handlers = list.AsReadOnly();
                }
            }

            return(handlers);
        }