diff options
Diffstat (limited to '')
| -rw-r--r-- | src/tools/WixToolset.HeatTasks/WixCommandLineBuilder.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/tools/WixToolset.HeatTasks/WixCommandLineBuilder.cs b/src/tools/WixToolset.HeatTasks/WixCommandLineBuilder.cs new file mode 100644 index 00000000..c3989902 --- /dev/null +++ b/src/tools/WixToolset.HeatTasks/WixCommandLineBuilder.cs | |||
| @@ -0,0 +1,56 @@ | |||
| 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.HeatTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using Microsoft.Build.Utilities; | ||
| 8 | |||
| 9 | /// <summary> | ||
| 10 | /// Helper class for appending the command line arguments. | ||
| 11 | /// </summary> | ||
| 12 | public class WixCommandLineBuilder : CommandLineBuilder | ||
| 13 | { | ||
| 14 | /// <summary> | ||
| 15 | /// Append a switch to the command line if the condition is true. | ||
| 16 | /// </summary> | ||
| 17 | /// <param name="switchName">Switch to append.</param> | ||
| 18 | /// <param name="condition">Condition specified by the user.</param> | ||
| 19 | public void AppendIfTrue(string switchName, bool condition) | ||
| 20 | { | ||
| 21 | if (condition) | ||
| 22 | { | ||
| 23 | this.AppendSwitch(switchName); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /// <summary> | ||
| 28 | /// Append a switch to the command line if any values in the array have been specified. | ||
| 29 | /// </summary> | ||
| 30 | /// <param name="switchName">Switch to append.</param> | ||
| 31 | /// <param name="values">Values specified by the user.</param> | ||
| 32 | public void AppendArrayIfNotNull(string switchName, IEnumerable<string> values) | ||
| 33 | { | ||
| 34 | if (values != null) | ||
| 35 | { | ||
| 36 | foreach (var value in values) | ||
| 37 | { | ||
| 38 | this.AppendSwitchIfNotNull(switchName, value); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | /// <summary> | ||
| 44 | /// Append arbitrary text to the command-line if specified. | ||
| 45 | /// </summary> | ||
| 46 | /// <param name="textToAppend">Text to append.</param> | ||
| 47 | public void AppendTextIfNotNull(string textToAppend) | ||
| 48 | { | ||
| 49 | if (!String.IsNullOrWhiteSpace(textToAppend)) | ||
| 50 | { | ||
| 51 | this.AppendSpaceIfNotEmpty(); | ||
| 52 | this.AppendTextUnquoted(textToAppend); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
