| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.BootstrapperApplicationApi |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | |
| 8 | /// <summary> |
| 9 | /// Default implementation of <see cref="IMbaCommand"/>. |
| 10 | /// </summary> |
| 11 | internal sealed class MbaCommand : IMbaCommand |
| 12 | { |
| 13 | public Restart Restart { get; internal set; } |
| 14 | |
| 15 | public string[] UnknownCommandLineArgs { get; internal set; } |
| 16 | |
| 17 | public KeyValuePair<string, string>[] Variables { get; internal set; } |
| 18 | |
| 19 | internal MbaCommand() { } |
| 20 | |
| 21 | public void SetOverridableVariables(IOverridableVariables overridableVariables, IEngine engine) |
| 22 | { |
| 23 | foreach (var kvp in this.Variables) |
| 24 | { |
| 25 | var key = kvp.Key; |
| 26 | |
| 27 | if (!overridableVariables.Variables.TryGetValue(key, out var overridableVariable)) |
| 28 | { |
| 29 | engine.Log(LogLevel.Error, String.Format("Ignoring attempt to set non-overridable variable: '{0}'.", key)); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | engine.SetVariableString(overridableVariable.Name, kvp.Value, false); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |