public override void Disconnect(IServer server, SessionEventArgs e) { try { HttpToken token = (HttpToken)e.Session.Tag; if (token != null) { if (token.Request != null) { token.Request.Response = null; } token.Request = null; } if (LogOutput == e.Session) { LogOutput = null; } HttpDisconnect?.Invoke(server, e); SessionControllerFactory.DisposedFactory(e.Session); base.Disconnect(server, e); } finally { e.Session.Tag = null; } }
public static SessionControllerFactory GetFactory(ISession session) { SessionControllerFactory factory = (SessionControllerFactory)session[FACTORY_TAG]; if (factory == null) { factory = new SessionControllerFactory(); factory.mServer = session.Server; session[FACTORY_TAG] = factory; } return(factory); }
internal ActionContext(ActionHandler handler, IHttpContext context, ActionHandlerFactory actionHandlerFactory) { Handler = handler; mFilters = handler.Filters; HttpContext = context; ActionHandlerFactory = actionHandlerFactory; Parameters = handler.GetParameters(context); Controller = handler.Controller; if (handler.InstanceType != InstanceType.Single) { if (handler.InstanceType == InstanceType.Session) { var factory = SessionControllerFactory.GetFactory(context.Session); Controller = factory[handler.ControllerUID]; if (Controller == null) { Controller = actionHandlerFactory.GetController(handler.ControllerType, context); if (Controller == null) { Controller = Activator.CreateInstance(handler.ControllerType); } factory[handler.ControllerUID] = Controller; } } else { Controller = actionHandlerFactory.GetController(handler.ControllerType, context); if (Controller == null) { Controller = Activator.CreateInstance(handler.ControllerType); } } } if (Controller == null) { Controller = handler.Controller; } }
public static void DisposedFactory(ISession session) { SessionControllerFactory factory = (SessionControllerFactory)session[FACTORY_TAG]; factory?.Dispose(); }