Exemple #1
0
 private InterpreterConfiguration(IReadOnlyDictionary <string, object> properties)
 {
     Id                      = Read(properties, nameof(Id));
     _description            = Read(properties, nameof(Description)) ?? "";
     InterpreterPath         = Read(properties, nameof(InterpreterPath));
     PathEnvironmentVariable = Read(properties, nameof(PathEnvironmentVariable));
     LibraryPath             = Read(properties, nameof(LibraryPath));
     Architecture            = InterpreterArchitecture.TryParse(Read(properties, nameof(Architecture)));
     try {
         Version = Version.Parse(Read(properties, nameof(Version)));
     } catch (Exception ex) when(ex is ArgumentException || ex is FormatException)
     {
         Version = new Version();
     }
     if (properties.TryGetValue(nameof(SearchPaths), out object o))
     {
         var sp = new List <string>();
         if (o is string s)
         {
             sp.AddRange(s.Split(';'));
         }
         else if (o is IEnumerable <string> ss)
         {
             sp.AddRange(ss);
         }
         SearchPaths = sp.ToArray();
     }
 }
Exemple #2
0
 private InterpreterConfiguration(IReadOnlyDictionary <string, object> properties)
 {
     InterpreterPath         = Read(properties, nameof(InterpreterPath));
     PathEnvironmentVariable = Read(properties, nameof(PathEnvironmentVariable));
     LibraryPath             = Read(properties, nameof(LibraryPath));
     Architecture            = InterpreterArchitecture.TryParse(Read(properties, nameof(Architecture)));
     try {
         Version = Version.Parse(Read(properties, nameof(Version)));
     } catch (Exception ex) when(ex is ArgumentException || ex is FormatException)
     {
         Version = new Version();
     }
 }
Exemple #3
0
 // Tests only
 internal InterpreterConfiguration(
     string interpreterPath  = null,
     string pathVar          = "",
     string libPath          = null,
     string sitePackagesPath = null,
     InterpreterArchitecture architecture = default,
     Version version = null)
 {
     InterpreterPath         = interpreterPath;
     PathEnvironmentVariable = pathVar;
     Architecture            = architecture ?? InterpreterArchitecture.Unknown;
     Version          = version ?? new Version();
     LibraryPath      = libPath ?? string.Empty;
     SitePackagesPath = sitePackagesPath ?? string.Empty;
 }
Exemple #4
0
 /// <summary>
 /// Constructs a new interpreter configuration based on the provided values.
 /// </summary>
 public InterpreterConfiguration(
     string id,
     string description,
     string interpreterPath  = null,
     string pathVar          = "",
     string libPath          = null,
     string sitePackagesPath = null,
     string typeshedPath     = null,
     string moduleCachePath  = null,
     InterpreterArchitecture architecture = default,
     Version version = null
     )
 {
     Id                      = id;
     _description            = description ?? string.Empty;
     InterpreterPath         = interpreterPath;
     PathEnvironmentVariable = pathVar;
     Architecture            = architecture ?? InterpreterArchitecture.Unknown;
     Version                 = version ?? new Version();
     LibraryPath             = libPath ?? string.Empty;
     SitePackagesPath        = sitePackagesPath ?? string.Empty;
     TypeshedPath            = typeshedPath ?? string.Empty;
     DatabasePath            = moduleCachePath ?? string.Empty;
 }