This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
PageHandlerExecutingContext.cs
76 lines (67 loc) · 3.21 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
67
68
69
70
71
72
73
74
75
76
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
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)
{
if (handlerArguments == null)
{
throw new ArgumentNullException(nameof(handlerArguments));
}
if (handlerInstance == null)
{
throw new ArgumentNullException(nameof(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; }
}
}