From 2724cfee4c163f3297ee25edfd2372767cfd4945 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 19 Jul 2018 00:58:00 -0700 Subject: Move tool projects to Tools repo --- .../ExamplePreprocessorExtensionAndCommandLine.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs (limited to 'src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs') 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 @@ +// 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. + +namespace Example.Extension +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; + + internal class ExamplePreprocessorExtensionAndCommandLine : BasePreprocessorExtension, IExtensionCommandLine + { + private string exampleValueFromCommandLine; + + public IEnumerable CommandLineSwitches => throw new NotImplementedException(); + + public ExamplePreprocessorExtensionAndCommandLine() + { + this.Prefixes = new[] { "ex" }; + } + + public void PreParse(ICommandLineContext context) + { + } + + public bool TryParseArgument(IParseCommandLine parseCommandLine, string arg) + { + if (parseCommandLine.IsSwitch(arg) && arg.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase)) + { + this.exampleValueFromCommandLine = parseCommandLine.GetNextArgumentOrError(arg); + return true; + } + + return false; + } + + public void PostParse() + { + } + + public override string GetVariableValue(string prefix, string name) + { + if (prefix == "ex" && "test".Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return String.IsNullOrWhiteSpace(this.exampleValueFromCommandLine) ? "(null)" : this.exampleValueFromCommandLine; + } + + return null; + } + } +} \ No newline at end of file -- cgit v1.2.3-55-g6feb