-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCallerIdentity.cs
58 lines (53 loc) · 1.38 KB
/
CallerIdentity.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
using System;
using System.Runtime.CompilerServices;
namespace SecurityDriven.TinyORM
{
using Utils;
/// <summary>
/// CallerIdentity class.
/// </summary>
sealed public class CallerIdentity
{
/// <summary>
/// Initializes a new instance of the <see cref="CallerIdentity"/> class.
/// </summary>
/// <param name="userId">The user id.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CallerIdentity(Guid userId)
{
this.UserId = userId;
}//ctor
Guid userId;
internal byte[] UserIdAsBytes;
/// <summary>
/// Gets the user id.
/// </summary>
/// <value>The user id.</value>
public Guid UserId
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return userId;
}
private set
{
userId = value;
if (value == Guid.Empty)
UserIdAsBytes = Util.ZeroLengthArray<byte>.Value;
else
UserIdAsBytes = value.ToByteArray();
}
}//UserId
/// <summary>
/// Gets the anonymous caller identity.
/// </summary>
/// <value>The anonymous caller identity.</value>
public static readonly CallerIdentity Anonymous = new CallerIdentity(Guid.Empty);
/// <summary>
/// Gets the anonymous caller identity delegate.
/// </summary>
/// <value>The anonymous caller identity delegate.</value>
public static readonly Func<CallerIdentity> AnonymousDelegate = () => Anonymous;
}// class CallerIdentity
}//ns