void IHttpModule.Init(HttpApplication context) { if (context == null) { throw new ArgumentNullException("context"); } if (SupportDiscoverability) { HttpModuleRegistry.RegisterInPartialTrust(context, this); } OnInit(context); }
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); }
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); }
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); }