Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created July 5, 2012 14:58
Show Gist options
  • Save jmarnold/3054190 to your computer and use it in GitHub Desktop.
Save jmarnold/3054190 to your computer and use it in GitHub Desktop.
Filters...
public class RequiresSiteAttribute : ModifyChainAttribute
{
public override void Alter(ActionCall call)
{
call.AddBefore(ActionCall.For<SiteFilter>(x => x.HasSite()));
}
}
public class SiteFilter
{
private readonly ISiteContext _context;
public SiteFilter(ISiteContext context)
{
_context = context;
}
public FubuContinuation HasSite()
{
return _context.Current == null
? FubuContinuation.RedirectTo(new SiteSelectionInput())
: FubuContinuation.NextBehavior();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment