-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathJsonRpcContext.cs
More file actions
44 lines (39 loc) · 1.33 KB
/
JsonRpcContext.cs
File metadata and controls
44 lines (39 loc) · 1.33 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AustinHarris.JsonRpc
{
/// <summary>
/// Provides access to a context specific to each JsonRpc method invocation.
/// This is a convienence class that wraps calls to Context specific methods on AustinHarris.JsonRpc.Handler
/// </summary>
public class JsonRpcContext
{
private JsonRpcContext(object value)
{
Value = value;
}
/// <summary>
/// The data associated with this context.
/// </summary>
public object Value { get; private set; }
/// <summary>
/// Allows you to set the exception used in in the JsonRpc response.
/// Warning: Must be called from within the execution context of the jsonRpc method to function.
/// </summary>
/// <param name="exception"></param>
public static void SetException(JsonRpcException exception)
{
Handler.RpcSetException(exception);
}
/// <summary>
/// Must be called from within the execution context of the jsonRpc Method to return the context
/// </summary>
/// <returns></returns>
public static JsonRpcContext Current()
{
return new JsonRpcContext(Handler.RpcContext());
}
}
}