namespace Geekeey.Extensions.Process; /// /// Builder that helps configure environment variables. /// public sealed class EnvironmentVariablesBuilder { private readonly Dictionary _vars = new(StringComparer.Ordinal); /// /// Sets an environment variable with the specified name to the specified value. /// public EnvironmentVariablesBuilder Set(string name, string? value) { _vars[name] = value; return this; } /// /// Sets multiple environment variables from the specified sequence of key-value pairs. /// public EnvironmentVariablesBuilder Set(IEnumerable> variables) { foreach (var (name, value) in variables) { Set(name, value); } return this; } /// /// Sets multiple environment variables from the specified dictionary. /// public EnvironmentVariablesBuilder Set(IReadOnlyDictionary variables) => Set((IEnumerable>)variables); /// /// Builds the resulting environment variables. /// public IReadOnlyDictionary Build() => new Dictionary(_vars, _vars.Comparer); }