using System.Collections.Generic;
using System.Xml.Linq;
namespace CADRuntime
{
///
/// Provides access functions to those parts of the CADPythonShell.xml file
/// that are also used in RpsAddin deployments.
///
public class NpsConfig : IRpsConfig
{
///
/// The full path to the settings file used
///
private readonly string _settingsPath;
private readonly XDocument _settings;
private readonly SettingsDictionary _dict;
public NpsConfig(string settingsFilePath)
{
_settingsPath = settingsFilePath;
_settings = XDocument.Load(_settingsPath);
_dict = new SettingsDictionary(_settingsPath);
}
///
/// Returns a list of search paths to be added to python interpreter engines.
///
public IEnumerable GetSearchPaths()
{
foreach (var searchPathNode in _settings.Root.Descendants("SearchPath"))
{
yield return searchPathNode.Attribute("name").Value;
}
yield return System.IO.Path.GetDirectoryName(_settingsPath);
}
///
/// Returns the list of variables to be included with the scope in CADPythonShell scripts.
///
public IDictionary GetVariables()
{
return _dict;
}
}
}