static Response InitSession(NancyContext ctx, MemorySession sessionStore)
        {
            if (ctx.Request == null)
            {
                return(null);
            }

            ctx.Request.Session          = sessionStore.Load(ctx.Request);
            ctx.Request.Session["Logic"] = new BaseLogic(ctx.Request.Session);

            return(null);
        }
        static Response InitSession(NancyContext ctx, MemorySession sessionStore)
        {
            if (ctx.Request == null)
            {
                return null;
            }

            ctx.Request.Session = sessionStore.Load(ctx.Request);
            ctx.Request.Session["Logic"] = new BaseLogic(ctx.Request.Session);

            return null;
        }
        public static IObjectSerializerSelector Enable(IPipelines pipelines)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            var sessionStore = new MemorySession();

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => InitSession(ctx, sessionStore));
            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => SaveSession(ctx, sessionStore));

            return(sessionStore);
        }
        public static IObjectSerializerSelector Enable(IPipelines pipelines)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            var sessionStore = new MemorySession();

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => InitSession(ctx, sessionStore));
            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => SaveSession(ctx, sessionStore));

            return sessionStore;
        }
 static void SaveSession(NancyContext ctx, MemorySession sessionStore)
 {
     ctx.Request.Session["Logic"] = null;
     sessionStore.Save(ctx.Request.Session, ctx.Response);
 }
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     StaticConfiguration.DisableErrorTraces = false;
     MemorySession.Enable(pipelines);
 }
 static void SaveSession(NancyContext ctx, MemorySession sessionStore)
 {
     ctx.Request.Session["Logic"] = null;
     sessionStore.Save(ctx.Request.Session, ctx.Response);
 }