forked from chuongmep/CadPythonShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCpsConfig.cs
More file actions
47 lines (42 loc) · 1.45 KB
/
CpsConfig.cs
File metadata and controls
47 lines (42 loc) · 1.45 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
37
38
39
40
41
42
43
44
45
46
47
using System.Collections.Generic;
using System.Xml.Linq;
namespace CADRuntime
{
/// <summary>
/// Provides access functions to those parts of the CADPythonShell.xml file
/// that are also used in CPS Plugin deployments.
/// </summary>
public class CpsConfig : ICpsConfig
{
/// <summary>
/// The full path to the settings file used
/// </summary>
private readonly string _settingsPath;
private readonly XDocument _settings;
private readonly SettingsDictionary _dict;
public CpsConfig(string settingsFilePath)
{
_settingsPath = settingsFilePath;
_settings = XDocument.Load(_settingsPath);
_dict = new SettingsDictionary(_settingsPath);
}
/// <summary>
/// Returns a list of search paths to be added to python interpreter engines.
/// </summary>
public IEnumerable<string> GetSearchPaths()
{
foreach (var searchPathNode in _settings.Root.Descendants("SearchPath"))
{
yield return searchPathNode.Attribute("name").Value;
}
yield return System.IO.Path.GetDirectoryName(_settingsPath);
}
/// <summary>
/// Returns the list of variables to be included with the scope in CADPythonShell scripts.
/// </summary>
public IDictionary<string, string> GetVariables()
{
return _dict;
}
}
}