forked from zzzprojects/System.Linq.Dynamic.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnowflakeId.cs
More file actions
57 lines (47 loc) · 1.36 KB
/
SnowflakeId.cs
File metadata and controls
57 lines (47 loc) · 1.36 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
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace System.Linq.Dynamic.Core.Tests.Helpers.Models
{
public struct SnowflakeId : IEquatable<SnowflakeId>
{
public bool Equals(SnowflakeId other)
{
return Value == other.Value;
}
public override bool Equals(object obj)
{
return obj is SnowflakeId other && Equals(other);
}
public override int GetHashCode()
{
return Value.GetHashCode();
}
public static bool operator ==(SnowflakeId left, SnowflakeId right)
{
return left.Equals(right);
}
public static bool operator !=(SnowflakeId left, SnowflakeId right)
{
return !left.Equals(right);
}
public static bool operator ==(SnowflakeId left, int right)
{
return (int)left.Value == right;
}
public static bool operator !=(SnowflakeId left, int right)
{
return (int)left.Value != right;
}
public static bool operator ==(SnowflakeId left, ulong right)
{
return left.Value == right;
}
public static bool operator !=(SnowflakeId left, ulong right)
{
return left.Value != right;
}
public ulong Value { get; }
public SnowflakeId(ulong value)
{
Value = value;
}
}
}