-
Notifications
You must be signed in to change notification settings - Fork 9.9k
/
PageHandlerExecutingContext.cs
66 lines (57 loc) · 2.77 KB
/
PageHandlerExecutingContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
namespace Microsoft.AspNetCore.Mvc.Filters;
/// <summary>
/// A context for page filters, used specifically in
/// <see cref="IPageFilter.OnPageHandlerExecuting(PageHandlerExecutingContext)"/> and
/// <see cref="IAsyncPageFilter.OnPageHandlerExecutionAsync(PageHandlerExecutingContext, PageHandlerExecutionDelegate)"/>.
/// </summary>
public class PageHandlerExecutingContext : FilterContext
{
/// <summary>
/// Creates a new instance of <see cref="PageHandlerExecutingContext"/>.
/// </summary>
/// <param name="pageContext">The <see cref="PageContext"/> associated with the current request.</param>
/// <param name="filters">The set of filters associated with the page.</param>
/// <param name="handlerMethod">The handler method to be invoked, may be null.</param>
/// <param name="handlerArguments">The arguments to provide to the handler method.</param>
/// <param name="handlerInstance">The handler instance associated with the page.</param>
public PageHandlerExecutingContext(
PageContext pageContext,
IList<IFilterMetadata> filters,
HandlerMethodDescriptor? handlerMethod,
IDictionary<string, object?> handlerArguments,
object handlerInstance)
: base(pageContext, filters)
{
ArgumentNullException.ThrowIfNull(handlerArguments);
ArgumentNullException.ThrowIfNull(handlerInstance);
HandlerMethod = handlerMethod;
HandlerArguments = handlerArguments;
HandlerInstance = handlerInstance;
}
/// <summary>
/// Gets the descriptor associated with the current page.
/// </summary>
public new virtual CompiledPageActionDescriptor ActionDescriptor =>
(CompiledPageActionDescriptor)base.ActionDescriptor;
/// <summary>
/// Gets or sets the <see cref="IActionResult"/> to execute. Setting <see cref="Result"/> to a non-<c>null</c>
/// value inside a page filter will short-circuit the page and any remaining page filters.
/// </summary>
public virtual IActionResult? Result { get; set; }
/// <summary>
/// Gets the arguments to pass when invoking the handler method. Keys are parameter names.
/// </summary>
public virtual IDictionary<string, object?> HandlerArguments { get; }
/// <summary>
/// Gets the descriptor for the handler method about to be invoked.
/// </summary>
public virtual HandlerMethodDescriptor? HandlerMethod { get; }
/// <summary>
/// Gets the object instance containing the handler method.
/// </summary>
public virtual object HandlerInstance { get; }
}