aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Ncm/ApplicationId.cs
blob: 24b7d9cab4f78d49955649d067cb121345303176 (plain) (blame)
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
namespace Ryujinx.Horizon.Sdk.Ncm
{
    public readonly struct ApplicationId
    {
        public readonly ulong Id;

        public static int Length => sizeof(ulong);

        public static ApplicationId First => new(0x0100000000010000);

        public static ApplicationId Last => new(0x01FFFFFFFFFFFFFF);

        public static ApplicationId Invalid => new(0);

        public bool IsValid => Id >= First.Id && Id <= Last.Id;

        public ApplicationId(ulong id)
        {
            Id = id;
        }

        public override bool Equals(object obj)
        {
            return obj is ApplicationId applicationId && applicationId.Equals(this);
        }

        public bool Equals(ApplicationId other)
        {
            return other.Id == Id;
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

        public static bool operator ==(ApplicationId lhs, ApplicationId rhs)
        {
            return lhs.Equals(rhs);
        }

        public static bool operator !=(ApplicationId lhs, ApplicationId rhs)
        {
            return !lhs.Equals(rhs);
        }

        public override string ToString()
        {
            return $"0x{Id:x}";
        }
    }
}