Skip to content

Commit

Permalink
Add GetSessionBag extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Sep 13, 2014
1 parent e775c9e commit 93d34d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ServiceStack/SessionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,16 @@ public static void ClearSession(this ICacheClient cache, IRequest httpReq = null
{
cache.Remove(GetSessionKey(httpReq));
}

public static ISession GetSessionBag(this IRequest request)
{
var factory = request.TryResolve<ISessionFactory>() ?? new SessionFactory(request.GetCacheClient());
return factory.GetOrCreateSession(request, request.Response);
}

public static ISession GetSessionBag(this IServiceBase service)
{
return service.Request.GetSessionBag();
}
}
}

0 comments on commit 93d34d7

Please sign in to comment.