internal void SaveInterpreterOptions() { _interpreterRegistry.BeginSuppressInterpretersChangedEvent(); try { _interpreterOptionsService.DefaultInterpreterId = GlobalInterpreterOptions.DefaultInterpreter; // Remove any items foreach (var option in InterpreterOptions.Select(kv => kv.Value).Where(o => o.Removed).ToList()) { _interpreterOptionsService.RemoveConfigurableInterpreter(option._config.Id); RemoveInterpreterOptions(option._config.Id); } // Add or update any items that weren't removed foreach (var option in InterpreterOptions.Select(x => x.Value)) { if (option.Added) { if (String.IsNullOrWhiteSpace(option.Id)) { option.Id = Guid.NewGuid().ToString(); } option.Added = false; } if (option.IsConfigurable) { // save configurable interpreter options var actualFactory = _interpreterOptionsService.AddConfigurableInterpreter( option.Description, new InterpreterConfiguration( option.Id, option.Description, !String.IsNullOrWhiteSpace(option.InterpreterPath) ? PathUtils.GetParent(option.InterpreterPath) : "", option.InterpreterPath ?? "", option.WindowsInterpreterPath ?? "", option.PathEnvironmentVariable ?? "", InterpreterArchitecture.TryParse(option.Architecture), Version.Parse(option.Version) ?? new Version(2, 7) ) ); } } foreach (var factory in InterpreterOptions.Where(x => x.Value.Id.StartsWith("Placeholder;")).ToArray()) { RemoveInterpreterOptions(factory.Value.Id); } } finally { _interpreterRegistry.EndSuppressInterpretersChangedEvent(); } }
internal void SaveInterpreterOptions() { _interpreterOptionsService.BeginSuppressInterpretersChangedEvent(); try { var configurable = _interpreterOptionsService.KnownProviders.OfType <ConfigurablePythonInterpreterFactoryProvider>().FirstOrDefault(); Debug.Assert(configurable != null); if (configurable != null) { // Remove any items foreach (var option in InterpreterOptions.Select(kv => kv.Value).Where(o => o.Removed).ToList()) { configurable.RemoveInterpreter(option.Id); RemoveInteractiveOptions(option.Factory); RemoveInterpreterOptions(option.Factory); } // Add or update any items that weren't removed foreach (var option in InterpreterOptions.Select(x => x.Value)) { if (option.Added) { if (option.Id == Guid.Empty) { option.Id = Guid.NewGuid(); } option.Added = false; } if (option.IsConfigurable) { // save configurable interpreter options var actualFactory = configurable.SetOptions( new InterpreterFactoryCreationOptions { Id = option.Id, InterpreterPath = option.InterpreterPath ?? "", WindowInterpreterPath = option.WindowsInterpreterPath ?? "", LibraryPath = option.LibraryPath ?? "", PathEnvironmentVariableName = option.PathEnvironmentVariable ?? "", ArchitectureString = option.Architecture ?? "x86", LanguageVersionString = option.Version ?? "2.7", Description = option.Display, } ); if (option.InteractiveOptions != null) { option.InteractiveOptions._id = GetInteractivePath(actualFactory); option.InteractiveOptions.Save(actualFactory); } } } } foreach (var factory in InterpreterOptions.Select(x => x.Key).OfType <InterpreterPlaceholder>().ToArray()) { RemoveInterpreterOptions(factory); } } finally { _interpreterOptionsService.EndSuppressInterpretersChangedEvent(); } }