public override string GetPropertyValue(string propertyName, ILaunchSettings launchSettings) { if (propertyName != EnvironmentVariablesPropertyName) { throw new InvalidOperationException($"{nameof(ActiveLaunchProfileEnvironmentVariableValueProvider)} does not handle property '{propertyName}'."); } return(LaunchProfileEnvironmentVariableEncoding.Format(launchSettings.ActiveProfile)); }
public override bool SetPropertyValue(string propertyName, string value, IWritableLaunchSettings launchSettings) { if (propertyName != EnvironmentVariablesPropertyName) { throw new InvalidOperationException($"{nameof(ActiveLaunchProfileEnvironmentVariableValueProvider)} does not handle property '{propertyName}'."); } var activeProfile = launchSettings.ActiveProfile; if (activeProfile == null) { return(false); } LaunchProfileEnvironmentVariableEncoding.ParseIntoDictionary(value, activeProfile.EnvironmentVariables); return(true); }
/// <returns> /// If the profile does not exist, returns <see langword="null"/>. Otherwise, returns the value /// of the property if the property is not defined, or <see langword="null"/> otherwise. The /// standard properties are always considered to be defined. /// </returns> public async Task <string?> GetUnevaluatedPropertyValueAsync(string propertyName) { ILaunchSettings snapshot = await _launchSettingsProvider.WaitForFirstSnapshot(); ILaunchProfile?profile = snapshot.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(p.Name, _context.ItemName)); if (profile is null) { return(null); } return(propertyName switch { CommandNamePropertyName => profile.CommandName ?? string.Empty, ExecutablePathPropertyName => profile.ExecutablePath ?? string.Empty, CommandLineArgumentsPropertyName => profile.CommandLineArgs ?? string.Empty, WorkingDirectoryPropertyName => profile.WorkingDirectory ?? string.Empty, LaunchBrowserPropertyName => profile.LaunchBrowser ? "true" : "false", LaunchUrlPropertyName => profile.LaunchUrl ?? string.Empty, EnvironmentVariablesPropertyName => LaunchProfileEnvironmentVariableEncoding.Format(profile), _ => GetExtensionPropertyValue(propertyName, profile, snapshot.GlobalSettings) });