Created
March 5, 2012 22:45
-
-
Save AlexZeitler/1981708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// This filter will manage the session for all of the controllers that needs a Raven Document Session. | |
| /// It does so by automatically injecting a session to the first public property of type IDocumentSession available | |
| /// on the controller. | |
| /// </summary> | |
| public class RavenActionFilterAttribute : ActionFilterAttribute { | |
| public override void OnActionExecuting(HttpActionContext filterContext) { | |
| filterContext.Request.Properties["RavenDocumentStore"] = | |
| DocumentStoreHolder.TryAddSession(filterContext.ControllerContext.Controller); | |
| } | |
| public override void OnActionExecuted(HttpActionExecutedContext filterContext) | |
| { | |
| DocumentStoreHolder | |
| .TryComplete(filterContext.ActionContext.ControllerContext.Controller, filterContext.Exception == null); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment