feat: initial project commit
Some checks failed
default / default (8.0) (push) Failing after 23s

This commit is contained in:
Louis Seubert 2024-04-27 20:15:05 +02:00
commit 5a825ffab2
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
52 changed files with 3780 additions and 0 deletions

View file

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