private void SaveDefaultInterpreter(string id) { using (var interpreterOptions = Registry.CurrentUser.CreateSubKey(DefaultInterpreterOptionsCollection, true)) { if (id == null) { interpreterOptions.SetValue(DefaultInterpreterSetting, ""); } else { Debug.Assert(!InterpreterRegistryConstants.IsNoInterpretersFactory(id)); interpreterOptions.SetValue(DefaultInterpreterSetting, id); } } }
private void SaveDefaultInterpreterId() { var id = _defaultInterpreterId; BeginSuppressDefaultInterpreterChangeEvent(); try { using (var interpreterOptions = Registry.CurrentUser.CreateSubKey(DefaultInterpreterOptionsCollection, true)) { if (string.IsNullOrEmpty(id)) { interpreterOptions.DeleteValue(DefaultInterpreterSetting, false); } else { Debug.Assert(!InterpreterRegistryConstants.IsNoInterpretersFactory(id)); interpreterOptions.SetValue(DefaultInterpreterSetting, id); } } } finally { EndSuppressDefaultInterpreterChangeEvent(); } }
/// <summary> /// Checks whether the configuration can be run and throws the /// appropriate exception if it cannot. /// </summary> /// <exception cref="ArgumentNullException"> /// config is null and parameterName is provided. /// </exception> /// <exception cref="NullReferenceException"> /// config is null and parameterName is not provided. /// </exception> /// <exception cref="NoInterpretersException"> /// config is the sentinel used when no environments are installed. /// </exception> /// <exception cref="FileNotFoundException"> /// config's InterpreterPath does not exist on disk. /// </exception> public static void ThrowIfNotRunnable(this InterpreterConfiguration config, string parameterName = null) { if (config == null) { if (string.IsNullOrEmpty(parameterName)) { throw new NullReferenceException(); } else { throw new ArgumentNullException(parameterName); } } else if (InterpreterRegistryConstants.IsNoInterpretersFactory(config.Id)) { throw new NoInterpretersException(); } else if (!File.Exists(config.InterpreterPath)) { throw new FileNotFoundException(config.InterpreterPath ?? "(null)"); } }
/// <summary> /// Returns true if the configuration can be run. This checks whether /// the configured InterpreterPath value is an actual file. /// </summary> public static bool IsRunnable(this InterpreterConfiguration config) { return(config != null && !InterpreterRegistryConstants.IsNoInterpretersFactory(config.Id) && File.Exists(config.InterpreterPath)); }