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(); } }
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(); } }
// 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; }
/// <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; }