forked from akpaevj/OneSTools.PS.TechLog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeadlockConnectionIntersectionsPair.cs
More file actions
36 lines (30 loc) · 1.44 KB
/
DeadlockConnectionIntersectionsPair.cs
File metadata and controls
36 lines (30 loc) · 1.44 KB
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
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace OneSTools.PS.TechLog
{
public class DeadlockConnectionIntersectionsPair
{
public long Waiter { get; }
public long Locker { get; }
public string Region { get; }
public string BlockingMode { get; }
public List<KeyValuePair<string, string>> FieldValues { get; } = new List<KeyValuePair<string, string>>();
public DeadlockConnectionIntersectionsPair(string data)
{
Waiter = long.Parse(Regex.Match(data, @"^\d+", RegexOptions.ExplicitCapture).Value);
Locker = long.Parse(Regex.Match(data, @"(?<=^\d+) \d+", RegexOptions.ExplicitCapture).Value);
Region = Regex.Match(data, @"(?<=^\d+ \d+ )\w+\.\w+", RegexOptions.ExplicitCapture).Value;
BlockingMode = Regex.Match(data, @"(?<=^\d+ \d+ \w+\.\w+ )\w+", RegexOptions.ExplicitCapture).Value;
var fields = Regex.Matches(data, @"\w+=.*?(?=( \w+=|$))", RegexOptions.ExplicitCapture);
foreach (Match fieldMatch in fields)
{
var fieldData = fieldMatch.Value;
var splitIndex = fieldData.IndexOf('=');
var field = fieldData.Substring(0, splitIndex);
var value = fieldData.Substring(splitIndex + 1);
FieldValues.Add(new KeyValuePair<string, string>(field, value.Trim('"')));
}
}
}
}