Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Add a new filter type for pages #6331

Closed
rynowak opened this issue May 26, 2017 · 2 comments
Closed

Add a new filter type for pages #6331

rynowak opened this issue May 26, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@rynowak
Copy link
Member

rynowak commented May 26, 2017

Something like:

public delegate Task<PageHandlerExecutedContext> PageExecutionDelegate();

public class PageHandlerSelectedContext : FilterContext
{
    public virtual new CompiledPageActionDescriptor ActionDescriptor { get; }

    public virtual HandlerMethodDescriptor HandlerMethod { get; set; }

    public virtual IActionResult Result { get; set; }

    public virtual object HandlerInstance { get; }
}


public class PageHandlerExecutingContext : FilterContext
{
    public virtual new CompiledPageActionDescriptor ActionDescriptor { get; }

    public virtual HandlerMethodDescriptor HandlerMethod { get; }

    public virtual IActionResult Result { get; set; }

    public virtual IDictionary<string, object> HandlerArguments { get; }

    public virtual object HandlerInstance { get; }
}


public class PageHandlerExecutedContext : FilterContext
{
    public virtual new CompiledPageActionDescriptor ActionDescriptor { get; }

    public virtual HandlerMethodDescriptor HandlerMethod { get; }

    public virtual IActionResult Result { get; set; }

    public virtual object HandlerInstance { get; }

    public virtual bool Canceled { get; set; }

    public virtual Exception Exception { get; set; }

    public virtual ExceptionDispatchInfo ExceptionDispatchInfo { get; set; }

    public virtual bool ExceptionHandled { get; set; }
}

public interface IPageFilter : IFilterMetadata
{
    void OnPageHandlerSelected(PageHandlerSelectedContext context);

    void OnPageHandlerExecuting(PageHandlerExecutingContext context);

    void OnPageHandlerExecuted(PageHandlerExecutedContext context);
}

public interface IAsyncPageFilter : IFilterMetadata
{
    void OnPageHandlerSelection(PageHandlerSelectedContext context);

    void OnPageHandlerExecution(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next);
}


@rynowak
Copy link
Member Author

rynowak commented May 26, 2017

This is a fun new thing!

You can use the OnPageHandlerSelection event to change what handler is selected, or even just to run arbitrary init code that takes place before model binding.

You can use the OnPageHandlerExection event to do all of the traditional action filter kinds of things

@rynowak
Copy link
Member Author

rynowak commented Jun 5, 2017

b796bc0

@rynowak rynowak closed this as completed Jun 5, 2017
@rynowak rynowak self-assigned this Jun 5, 2017
@rynowak rynowak added this to the 2.0.0-preview3 milestone Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant