using System; using System.Collections.Generic; namespace VNLib.Tools.Build.Executor.Model { /// /// Represents a collection of taskfile "environment" variables /// public sealed class TaskfileVars { private readonly Dictionary vars; public TaskfileVars() { vars = new(StringComparer.OrdinalIgnoreCase); } private TaskfileVars(IEnumerable> values) { vars = new(values, StringComparer.OrdinalIgnoreCase); } /// /// Gets all variables as a readonly dictionary /// /// The collection of environment variables public IReadOnlyDictionary GetVariables() => vars; /// /// Sets a taskfile environment variable /// /// The variable name /// The optional variable value public void Set(string key, string? value) => vars[key] = value ?? string.Empty; /// /// Removes a taskfile environment variable /// /// The name of the variable to remove public void Remove(string key) => vars.Remove(key); /// /// Clones the current taskfile variables into an independent instance /// /// The new instance public TaskfileVars Clone() => new (vars); } }