diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-19 00:58:00 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-21 07:36:59 -0700 |
| commit | 2724cfee4c163f3297ee25edfd2372767cfd4945 (patch) | |
| tree | 8cdda34c83bea014a586a491e3b4b187ad8f16da /src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs | |
| parent | 4d40bef9cf51b8cff7e1f6a73fdf68b9722eb8a0 (diff) | |
| download | wix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.gz wix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.bz2 wix-2724cfee4c163f3297ee25edfd2372767cfd4945.zip | |
Move tool projects to Tools repo
Diffstat (limited to 'src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs')
| -rw-r--r-- | src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs new file mode 100644 index 00000000..6f86e20d --- /dev/null +++ b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs | |||
| @@ -0,0 +1,50 @@ | |||
| 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 Example.Extension | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using WixToolset.Extensibility; | ||
| 8 | using WixToolset.Extensibility.Services; | ||
| 9 | |||
| 10 | internal class ExamplePreprocessorExtensionAndCommandLine : BasePreprocessorExtension, IExtensionCommandLine | ||
| 11 | { | ||
| 12 | private string exampleValueFromCommandLine; | ||
| 13 | |||
| 14 | public IEnumerable<ExtensionCommandLineSwitch> CommandLineSwitches => throw new NotImplementedException(); | ||
| 15 | |||
| 16 | public ExamplePreprocessorExtensionAndCommandLine() | ||
| 17 | { | ||
| 18 | this.Prefixes = new[] { "ex" }; | ||
| 19 | } | ||
| 20 | |||
| 21 | public void PreParse(ICommandLineContext context) | ||
| 22 | { | ||
| 23 | } | ||
| 24 | |||
| 25 | public bool TryParseArgument(IParseCommandLine parseCommandLine, string arg) | ||
| 26 | { | ||
| 27 | if (parseCommandLine.IsSwitch(arg) && arg.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase)) | ||
| 28 | { | ||
| 29 | this.exampleValueFromCommandLine = parseCommandLine.GetNextArgumentOrError(arg); | ||
| 30 | return true; | ||
| 31 | } | ||
| 32 | |||
| 33 | return false; | ||
| 34 | } | ||
| 35 | |||
| 36 | public void PostParse() | ||
| 37 | { | ||
| 38 | } | ||
| 39 | |||
| 40 | public override string GetVariableValue(string prefix, string name) | ||
| 41 | { | ||
| 42 | if (prefix == "ex" && "test".Equals(name, StringComparison.OrdinalIgnoreCase)) | ||
| 43 | { | ||
| 44 | return String.IsNullOrWhiteSpace(this.exampleValueFromCommandLine) ? "(null)" : this.exampleValueFromCommandLine; | ||
| 45 | } | ||
| 46 | |||
| 47 | return null; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } \ No newline at end of file | ||
