Beispiel #1
0
        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();
            }
        }