3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using Microsoft . AspNetCore . Authorization ;
6
+ using System . Linq ;
7
+ using System . Reflection ;
8
+ using Microsoft . Extensions . Internal ;
7
9
8
10
namespace Microsoft . AspNetCore . SignalR
9
11
{
@@ -12,16 +14,27 @@ namespace Microsoft.AspNetCore.SignalR
12
14
/// </summary>
13
15
public class HubInvocationContext
14
16
{
17
+ internal ObjectMethodExecutor ObjectMethodExecutor { get ; }
18
+
15
19
/// <summary>
16
20
/// Instantiates a new instance of the <see cref="HubInvocationContext"/> class.
17
21
/// </summary>
18
22
/// <param name="context">Context for the active Hub connection and caller.</param>
19
- /// <param name="hubType">The type of the Hub.</param>
20
- /// <param name="hubMethodName">The name of the Hub method being invoked.</param>
23
+ /// <param name="serviceProvider">The <see cref="IServiceProvider"/> specific to the scope of this Hub method invocation.</param>
24
+ /// <param name="hub">The instance of the Hub.</param>
25
+ /// <param name="hubMethod">The <see cref="MethodInfo"/> for the Hub method being invoked.</param>
21
26
/// <param name="hubMethodArguments">The arguments provided by the client.</param>
22
- public HubInvocationContext ( HubCallerContext context , Type hubType , string hubMethodName , object [ ] hubMethodArguments ) : this ( context , hubMethodName , hubMethodArguments )
27
+ public HubInvocationContext ( HubCallerContext context , IServiceProvider serviceProvider , Hub hub , MethodInfo hubMethod , IReadOnlyList < object > hubMethodArguments )
23
28
{
24
- HubType = hubType ;
29
+ Hub = hub ;
30
+ ServiceProvider = serviceProvider ;
31
+ HubMethod = hubMethod ;
32
+ HubMethodArguments = hubMethodArguments ;
33
+ Context = context ;
34
+
35
+ #pragma warning disable CS0618 // Type or member is obsolete
36
+ HubMethodName = HubMethod . Name ;
37
+ #pragma warning restore CS0618 // Type or member is obsolete
25
38
}
26
39
27
40
/// <summary>
@@ -30,11 +43,16 @@ public HubInvocationContext(HubCallerContext context, Type hubType, string hubMe
30
43
/// <param name="context">Context for the active Hub connection and caller.</param>
31
44
/// <param name="hubMethodName">The name of the Hub method being invoked.</param>
32
45
/// <param name="hubMethodArguments">The arguments provided by the client.</param>
46
+ [ Obsolete ( "This constructor is obsolete and will be removed in a future version. The recommended alternative is to use the other constructor." ) ]
33
47
public HubInvocationContext ( HubCallerContext context , string hubMethodName , object [ ] hubMethodArguments )
34
48
{
35
- HubMethodName = hubMethodName ;
36
- HubMethodArguments = hubMethodArguments ;
37
- Context = context ;
49
+ throw new NotSupportedException ( "This constructor no longer works. Use the other constructor." ) ;
50
+ }
51
+
52
+ internal HubInvocationContext ( ObjectMethodExecutor objectMethodExecutor , HubCallerContext context , IServiceProvider serviceProvider , Hub hub , object [ ] hubMethodArguments )
53
+ : this ( context , serviceProvider , hub , objectMethodExecutor . MethodInfo , hubMethodArguments )
54
+ {
55
+ ObjectMethodExecutor = objectMethodExecutor ;
38
56
}
39
57
40
58
/// <summary>
@@ -43,18 +61,29 @@ public HubInvocationContext(HubCallerContext context, string hubMethodName, obje
43
61
public HubCallerContext Context { get ; }
44
62
45
63
/// <summary>
46
- /// Gets the Hub type .
64
+ /// Gets the Hub instance .
47
65
/// </summary>
48
- public Type HubType { get ; }
66
+ public Hub Hub { get ; }
49
67
50
68
/// <summary>
51
69
/// Gets the name of the Hub method being invoked.
52
70
/// </summary>
71
+ [ Obsolete ( "This property is obsolete and will be removed in a future version. Use HubMethod.Name instead." ) ]
53
72
public string HubMethodName { get ; }
54
73
55
74
/// <summary>
56
75
/// Gets the arguments provided by the client.
57
76
/// </summary>
58
77
public IReadOnlyList < object > HubMethodArguments { get ; }
78
+
79
+ /// <summary>
80
+ /// The <see cref="IServiceProvider"/> specific to the scope of this Hub method invocation.
81
+ /// </summary>
82
+ public IServiceProvider ServiceProvider { get ; }
83
+
84
+ /// <summary>
85
+ /// The <see cref="MethodInfo"/> for the Hub method being invoked.
86
+ /// </summary>
87
+ public MethodInfo HubMethod { get ; }
59
88
}
60
89
}
0 commit comments