forked from trimble-oss/dba-dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlan.cs
53 lines (47 loc) · 1.41 KB
/
Plan.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
using System;
using System.Collections.Generic;
using System.Linq;
namespace DBADash
{
public class Plan : IEqualityComparer<Plan>
{
public readonly byte[] PlanHandle;
public readonly int StartOffset;
public readonly int EndOffset;
public readonly byte[] PlanHash;
public readonly string Key;
public Plan(byte[] planHandle, byte[] planHash, int startOffset, int endOffset)
{
PlanHandle = planHandle;
PlanHash = planHash;
StartOffset = startOffset;
EndOffset = endOffset;
Key = Convert.ToBase64String(PlanHandle.Concat(PlanHash).Concat(BitConverter.GetBytes(StartOffset)).Concat(BitConverter.GetBytes(EndOffset)).ToArray());
}
public override bool Equals(Object obj)
{
//Check for null and compare run-time types.
if ((obj == null) || GetType() != obj.GetType())
{
return false;
}
else
{
var p = (Plan)obj;
return p.Key == Key;
}
}
public bool Equals(Plan x, Plan y)
{
return x?.Key == y?.Key;
}
public override int GetHashCode()
{
return Key.GetHashCode();
}
public int GetHashCode(Plan obj)
{
return obj.Key.GetHashCode();
}
}
}