コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 static void SaveSession(NancyContext ctx, MemorySession sessionStore)
 {
     ctx.Request.Session["Logic"] = null;
     sessionStore.Save(ctx.Request.Session, ctx.Response);
 }
コード例 #6
0
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     StaticConfiguration.DisableErrorTraces = false;
     MemorySession.Enable(pipelines);
 }
コード例 #7
0
 static void SaveSession(NancyContext ctx, MemorySession sessionStore)
 {
     ctx.Request.Session["Logic"] = null;
     sessionStore.Save(ctx.Request.Session, ctx.Response);
 }