forked from akpaevj/OneSTools.PS.TechLog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocksInfoRegion.cs
More file actions
34 lines (27 loc) · 1.14 KB
/
LocksInfoRegion.cs
File metadata and controls
34 lines (27 loc) · 1.14 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
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace OneSTools.PS.TechLog
{
public class LocksInfoRegion
{
public string Region { get; }
public string BlockingMode { get; }
public List<(string Field, string Values)> FieldValues { get; } = new List<(string, string)>();
public string Hash { get; }
public LocksInfoRegion(string locks)
{
Hash = TjEvent.GetMd5Hash(locks);
Region = Regex.Match(locks, @"^\w+\.\w+", RegexOptions.ExplicitCapture).Value;
BlockingMode = Regex.Match(locks, @"(?<=^\w+\.\w+ ).*?(?= )", RegexOptions.ExplicitCapture).Value;
var fields = Regex.Matches(locks, @"\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((field, value.Trim('"')));
}
}
}
}