-
Notifications
You must be signed in to change notification settings - Fork 2k
/
InvokeMethodRequest.cs
102 lines (87 loc) · 3.52 KB
/
InvokeMethodRequest.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
namespace Orleans.CodeGeneration
{
/// <summary>
/// Data object holding metadata associated with a grain Invoke request.
/// </summary>
[Serializable]
public sealed class InvokeMethodRequest
{
internal static IInvokeMethodRequestLoggingHelper Helper { get; set; }
/// <summary> InterfaceId for this Invoke request. </summary>
public int InterfaceId { get; private set; }
public ushort InterfaceVersion { get; private set; }
/// <summary> MethodId for this Invoke request. </summary>
public int MethodId { get; private set; }
/// <summary> Arguments for this Invoke request. </summary>
public object[] Arguments { get; private set; }
internal InvokeMethodRequest(int interfaceId, ushort interfaceVersion, int methodId, object[] arguments)
{
InterfaceId = interfaceId;
InterfaceVersion = interfaceVersion;
MethodId = methodId;
Arguments = arguments;
}
/// <summary>
/// String representation for this Invoke request.
/// </summary>
/// <remarks>
/// Note: This is not the serialized wire form of this Invoke request.
/// </remarks>
public override string ToString()
{
if (Helper != null)
{
Helper.GetInterfaceAndMethodName(this.InterfaceId, this.MethodId, out var interfaceName, out var methodName);
return $"InvokeMethodRequest {interfaceName}:{methodName}";
}
else
{
return $"InvokeMethodRequest {this.InterfaceId}:{this.MethodId}";
}
}
}
/// <summary>
/// Invoke options for an <c>InvokeMethodRequest</c>
/// </summary>
/// <remarks>
/// These flag values are used in Orleans generated invoker code, and should not be altered. </remarks>
[Flags]
public enum InvokeMethodOptions
{
/// <summary>No options defined.</summary>
None = 0,
/// <summary>Invocation is one-way with no feedback on whether the call succeeds or fails.</summary>
OneWay = 0x04,
/// <summary>Invocation is read-only and can interleave with other read-only invocations.</summary>
ReadOnly = 0x08,
/// <summary>Invocation does not care about ordering and can consequently be optimized.</summary>
Unordered = 0x10,
/// <summary>Obsolete field.</summary>
[Obsolete]
DelayForConsistency = 0x20,
/// <summary>The invocation can interleave with any other request type, including write requests.</summary>
AlwaysInterleave = 0x100,
// Transactional method options.
// NOTE: keep in sync with TransactionOption enum.
// We use a mask to define a set of bits we use for transaction options.
TransactionMask = 0xE00,
TransactionSuppress = 0x200,
TransactionCreateOrJoin = 0x400,
TransactionCreate = 0x600,
TransactionJoin = 0x800,
TransactionSupported = 0xA00,
TransactionNotAllowed = 0xC00,
}
public static class InvokeMethodOptionsExtensions
{
public static bool IsTransactional(this InvokeMethodOptions options)
{
return (options & InvokeMethodOptions.TransactionMask) != 0;
}
public static bool IsTransactionOption(this InvokeMethodOptions options, InvokeMethodOptions test)
{
return (options & InvokeMethodOptions.TransactionMask) == test;
}
}
}