Revize bab6f59d
Přidáno uživatelem Jakub Šilhavý před asi 3 roky(ů)
ld_client/LDClient/detection/DebuggerInfoParser.cs | ||
---|---|---|
1 |
using System.Text.RegularExpressions; |
|
2 |
|
|
3 |
namespace LDClient.detection { |
|
4 |
|
|
5 |
public static class DebuggerInfoParser { |
|
6 |
|
|
7 |
private const int ExpectedNumberOfMatches = 2; |
|
8 |
|
|
9 |
private static readonly Regex SerialNumberRegex = new("(?<=Serial Number: )(.*)"); |
|
10 |
|
|
11 |
public static (string headSerialNumber, string bodySerialNumber) Parse(string dataTxt) { |
|
12 |
var matches = SerialNumberRegex.Matches(dataTxt); |
|
13 |
|
|
14 |
if (matches.Count != ExpectedNumberOfMatches) { |
|
15 |
throw new ArgumentException($"Expected {ExpectedNumberOfMatches} matches to be found in the text (actually found: {matches.Count})"); |
|
16 |
} |
|
17 |
|
|
18 |
return (matches[0].ToString(), matches[1].ToString()); |
|
19 |
} |
|
20 |
} |
|
21 |
} |
ld_client/LDClient/utils/IoUtils.cs | ||
---|---|---|
1 |
namespace LDClient.utils { |
|
2 |
|
|
3 |
public static class IoUtils { |
|
4 |
|
|
5 |
public static string ReadFile(string filename) { |
|
6 |
return File.ReadAllLines(filename).Aggregate("", (current, line) => $"{current}{line}\n"); |
|
7 |
} |
|
8 |
} |
|
9 |
} |
Také k dispozici: Unified diff
re #9565 Implemented DebuggerInfoParser, added IoUtils for reading the content of a file