Skip to content

Commit 8b091bb

Browse files
committed
Extracted ISimpleScanComparer interface.
1 parent 01239e5 commit 8b091bb

14 files changed

+58
-79
lines changed

ReClass.NET/MemoryScanner/Comparer/ArrayOfBytesMemoryComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using System;
22
using System.Diagnostics;
33
using System.Diagnostics.Contracts;
44

55
namespace ReClassNET.MemoryScanner.Comparer
66
{
7-
public class ArrayOfBytesMemoryComparer : IScanComparer
7+
public class ArrayOfBytesMemoryComparer : ISimpleScanComparer
88
{
99
public ScanCompareType CompareType => ScanCompareType.Equal;
1010
public int ValueSize => bytePattern?.Length ?? byteArray.Length;

ReClass.NET/MemoryScanner/Comparer/ByteMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ReClassNET.MemoryScanner.Comparer
55
{
6-
public class ByteMemoryComparer : IScanComparer
6+
public class ByteMemoryComparer : ISimpleScanComparer
77
{
88
public ScanCompareType CompareType { get; }
99
public byte Value1 { get; }

ReClass.NET/MemoryScanner/Comparer/DoubleMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace ReClassNET.MemoryScanner.Comparer
66
{
7-
public class DoubleMemoryComparer : IScanComparer
7+
public class DoubleMemoryComparer : ISimpleScanComparer
88
{
99
public ScanCompareType CompareType { get; }
1010
public ScanRoundMode RoundType { get; }

ReClass.NET/MemoryScanner/Comparer/FloatMemoryComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using System;
22
using System.Diagnostics;
33
using ReClassNET.Extensions;
44

55
namespace ReClassNET.MemoryScanner.Comparer
66
{
7-
public class FloatMemoryComparer : IScanComparer
7+
public class FloatMemoryComparer : ISimpleScanComparer
88
{
99
public ScanCompareType CompareType { get; }
1010
public ScanRoundMode RoundType { get; }
Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,7 @@
1-
using System;
2-
using System.Diagnostics.Contracts;
3-
41
namespace ReClassNET.MemoryScanner.Comparer
52
{
6-
[ContractClass(typeof(ScanComparerContract))]
73
public interface IScanComparer
84
{
95
ScanCompareType CompareType { get; }
10-
int ValueSize { get; }
11-
12-
/// <summary>
13-
/// Compares the data at the provided index to the current <see cref="CompareType"/>.
14-
/// </summary>
15-
/// <param name="data">The byte array to be compared.</param>
16-
/// <param name="index">The index into the byte array.</param>
17-
/// <param name="result">[out] The scan result if the <see cref="CompareType"/> matched.</param>
18-
/// <returns>True if matched.</returns>
19-
bool Compare(byte[] data, int index, out ScanResult result);
20-
21-
/// <summary>
22-
/// Compares the data at the provided index to the current <see cref="CompareType"/>.
23-
/// The previous results may be used.
24-
/// </summary>
25-
/// <param name="data">The byte array to be compared.</param>
26-
/// <param name="index">The index into the byte array.</param>
27-
/// <param name="previous">Scan result to be compared.</param>
28-
/// <param name="result">[out] The scan result if the <see cref="CompareType"/> matched.</param>
29-
/// <returns>True if matched.</returns>
30-
bool Compare(byte[] data, int index, ScanResult previous, out ScanResult result);
31-
}
32-
33-
[ContractClassFor(typeof(IScanComparer))]
34-
internal abstract class ScanComparerContract : IScanComparer
35-
{
36-
public ScanCompareType CompareType => throw new NotImplementedException();
37-
38-
public int ValueSize
39-
{
40-
get
41-
{
42-
Contract.Ensures(ValueSize > 0);
43-
44-
throw new NotImplementedException();
45-
}
46-
}
47-
public bool Compare(byte[] data, int index, out ScanResult result)
48-
{
49-
Contract.Requires(data != null);
50-
Contract.Requires(index >= 0);
51-
52-
throw new NotImplementedException();
53-
}
54-
55-
public bool Compare(byte[] data, int index, ScanResult previous, out ScanResult result)
56-
{
57-
Contract.Requires(data != null);
58-
Contract.Requires(index >= 0);
59-
Contract.Requires(previous != null);
60-
61-
throw new NotImplementedException();
62-
}
636
}
647
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace ReClassNET.MemoryScanner.Comparer
2+
{
3+
public interface ISimpleScanComparer : IScanComparer
4+
{
5+
int ValueSize { get; }
6+
7+
/// <summary>
8+
/// Compares the data at the provided index to the current <see cref="IScanComparer.CompareType"/>.
9+
/// </summary>
10+
/// <param name="data">The byte array to be compared.</param>
11+
/// <param name="index">The index into the byte array.</param>
12+
/// <param name="result">[out] The scan result if the <see cref="IScanComparer.CompareType"/> matched.</param>
13+
/// <returns>True if matched.</returns>
14+
bool Compare(byte[] data, int index, out ScanResult result);
15+
16+
/// <summary>
17+
/// Compares the data at the provided index to the current <see cref="IScanComparer.CompareType"/>.
18+
/// The previous results may be used.
19+
/// </summary>
20+
/// <param name="data">The byte array to be compared.</param>
21+
/// <param name="index">The index into the byte array.</param>
22+
/// <param name="previous">Scan result to be compared.</param>
23+
/// <param name="result">[out] The scan result if the <see cref="IScanComparer.CompareType"/> matched.</param>
24+
/// <returns>True if matched.</returns>
25+
bool Compare(byte[] data, int index, ScanResult previous, out ScanResult result);
26+
}
27+
}

ReClass.NET/MemoryScanner/Comparer/IntegerMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ReClassNET.MemoryScanner.Comparer
55
{
6-
public class IntegerMemoryComparer : IScanComparer
6+
public class IntegerMemoryComparer : ISimpleScanComparer
77
{
88
public ScanCompareType CompareType { get; }
99
public int Value1 { get; }

ReClass.NET/MemoryScanner/Comparer/LongMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ReClassNET.MemoryScanner.Comparer
55
{
6-
public class LongMemoryComparer : IScanComparer
6+
public class LongMemoryComparer : ISimpleScanComparer
77
{
88
public ScanCompareType CompareType { get; }
99
public long Value1 { get; }

ReClass.NET/MemoryScanner/Comparer/ShortMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ReClassNET.MemoryScanner.Comparer
55
{
6-
public class ShortMemoryComparer : IScanComparer
6+
public class ShortMemoryComparer : ISimpleScanComparer
77
{
88
public ScanCompareType CompareType { get; }
99
public short Value1 { get; }

ReClass.NET/MemoryScanner/Comparer/StringMemoryComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ReClassNET.MemoryScanner.Comparer
77
{
8-
public class StringMemoryComparer : IScanComparer
8+
public class StringMemoryComparer : ISimpleScanComparer
99
{
1010
public ScanCompareType CompareType => ScanCompareType.Equal;
1111
public bool CaseSensitive { get; }

0 commit comments

Comments
 (0)