-
Notifications
You must be signed in to change notification settings - Fork 474
/
CMethodId.cs
57 lines (48 loc) · 1.49 KB
/
CMethodId.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
namespace SharpCompress.Common.SevenZip
{
internal readonly struct CMethodId
{
public const ulong K_COPY_ID = 0;
public const ulong K_LZMA_ID = 0x030101;
public const ulong K_LZMA2_ID = 0x21;
public const ulong K_AES_ID = 0x06F10701;
public static readonly CMethodId K_COPY = new CMethodId(K_COPY_ID);
public static readonly CMethodId K_LZMA = new CMethodId(K_LZMA_ID);
public static readonly CMethodId K_LZMA2 = new CMethodId(K_LZMA2_ID);
public static readonly CMethodId K_AES = new CMethodId(K_AES_ID);
public readonly ulong _id;
public CMethodId(ulong id)
{
_id = id;
}
public override int GetHashCode()
{
return _id.GetHashCode();
}
public override bool Equals(object? obj)
{
return obj is CMethodId other && Equals(other);
}
public bool Equals(CMethodId other)
{
return _id == other._id;
}
public static bool operator ==(CMethodId left, CMethodId right)
{
return left._id == right._id;
}
public static bool operator !=(CMethodId left, CMethodId right)
{
return left._id != right._id;
}
public int GetLength()
{
int bytes = 0;
for (ulong value = _id; value != 0; value >>= 8)
{
bytes++;
}
return bytes;
}
}
}