forked from AlexPlesa/Switch-Trados-Studios-Environment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstalledBuilds.cs
55 lines (48 loc) · 2.12 KB
/
InstalledBuilds.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
using Microsoft.Win32;
using System.Collections.Generic;
using System.Linq;
namespace Switch_Trados_Studios_Environment
{
public class InstalledBuilds
{
public List<string> listOfInstalledBuilds = new List<string>();
public Dictionary<int, string> studioBuildTypeDictionary = new Dictionary<int, string>();
public int nrOfInstalledBuilds;
public InstalledBuilds()
{
listOfInstalledBuilds = PopulateListOfInstalledBuilds();
studioBuildTypeDictionary = PopulateStudioDictionaries();
nrOfInstalledBuilds = studioBuildTypeDictionary.Count();
}
private List<string> PopulateListOfInstalledBuilds()
{
RegistryKey SdlInstallRegistry = Registry.LocalMachine.OpenSubKey(Constants.SdlInstallRegistryPath);
RegistryKey TradosInstallRegistry = Registry.LocalMachine.OpenSubKey(Constants.TradosInstallRegistryPath);
List<string> installedBuilds = new List<string>();
if (SdlInstallRegistry != null)
{
var installedStudioBuilds = SdlInstallRegistry.GetSubKeyNames()
.Where<string>(val => (val.Contains("Studio16") || val.Contains("Studio17")) && !val.Contains("License")).ToList();
installedBuilds.AddRange(installedStudioBuilds);
}
if (TradosInstallRegistry != null)
{
var installedStudioBuilds = TradosInstallRegistry.GetSubKeyNames()
.Where<string>(val => (val.Contains("Studio16") || val.Contains("Studio17")) && !val.Contains("License")).ToList();
installedBuilds.AddRange(installedStudioBuilds);
}
return installedBuilds;
}
private Dictionary<int, string> PopulateStudioDictionaries()
{
int Key = 0;
Dictionary<int, string> buildTypeDictionary = new Dictionary<int, string>();
foreach (string build in listOfInstalledBuilds)
{
buildTypeDictionary.Add(Key, build);
Key++;
}
return buildTypeDictionary;
}
}
}