-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGuidMapping.cs
71 lines (55 loc) · 1.75 KB
/
GuidMapping.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using GuidMapping.Properties;
namespace GuidMapping
{
public static class GuidMapping
{
private static readonly Dictionary<string, string> Guids;
private static readonly List<string> Ignore;
static GuidMapping()
{
//GUIDs to ignore
Ignore = new List<string>
{
"20000000-0000-0000-0000-000000000000",
"00000000-0000-0000-0000-000001000000",
"00000000-0000-0000-0000-000000000000"
};
string[] stringSeparators = {"\r\n"};
var lines = Resources.GuidToName.Split(stringSeparators, StringSplitOptions.None);
Guids = new Dictionary<string, string>();
foreach (var line in lines)
{
var segs = line.Split('|');
if (segs.Length != 2)
{
continue;
}
var id = segs[0].Trim().ToLowerInvariant();
var desc = segs[1].Trim();
if (id.Length != 36)
{
continue;
}
if (Guids.ContainsKey(id) == false)
{
Guids.Add(id, desc);
}
}
}
public static string GetDescriptionFromGuid(string guid)
{
var tempValue = guid.ToLowerInvariant();
if (tempValue.StartsWith("{"))
{
tempValue = tempValue.Replace("{","").Replace("}","");
}
if (Guids.ContainsKey(tempValue))
{
return Guids[tempValue];
}
return $"Unmapped GUID: {guid}";
}
}
}